diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-16 12:06:18 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-16 12:06:18 +0200 |
commit | 0734807eef5a6b638b06d57aef6ee59ac78a3456 (patch) | |
tree | 3af73fdc293ab18962078c1a92e07d803009f1f5 /db | |
parent | d0abc27c079f058c40a74b89e54bd21ba4aad53e (diff) | |
parent | ac48332166ce28fcb1a2fc130c7f5adbc760e42d (diff) |
Merge remote-tracking branch 'MyIgel/logentry-model'
Diffstat (limited to 'db')
-rw-r--r-- | db/migrations/2018_08_30_000000_create_log_entries_table.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/db/migrations/2018_08_30_000000_create_log_entries_table.php b/db/migrations/2018_08_30_000000_create_log_entries_table.php new file mode 100644 index 00000000..68815434 --- /dev/null +++ b/db/migrations/2018_08_30_000000_create_log_entries_table.php @@ -0,0 +1,47 @@ +<?php + +use Engelsystem\Database\Migration\Migration; +use Illuminate\Database\Schema\Blueprint; + +class CreateLogEntriesTable extends Migration +{ + /** + * Run the migration + */ + public function up() + { + $this->schema->create('log_entries', function (Blueprint $table) { + $table->increments('id'); + $table->string('level', 20); + $table->text('message'); + $table->timestamp('created_at')->nullable(); + }); + + $this->schema->getConnection()->unprepared(' + INSERT INTO log_entries (`id`, `level`, `message`, `created_at`) + SELECT `id`, `level`, `message`, FROM_UNIXTIME(`timestamp`) FROM LogEntries + '); + + $this->schema->dropIfExists('LogEntries'); + } + + /** + * Reverse the migration + */ + public function down() + { + $this->schema->create('LogEntries', function (Blueprint $table) { + $table->increments('id'); + $table->string('level', 20); + $table->text('message'); + $table->integer('timestamp'); + }); + + $this->schema->getConnection()->unprepared(' + INSERT INTO LogEntries (`id`, `level`, `message`, `timestamp`) + SELECT `id`, `level`, `message`, UNIX_TIMESTAMP(`created_at`) FROM log_entries + '); + + $this->schema->dropIfExists('log_entries'); + } +} |