From ac48332166ce28fcb1a2fc130c7f5adbc760e42d Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Fri, 31 Aug 2018 01:55:05 +0200 Subject: Models: Added LogEntry model --- .../2018_08_30_000000_create_log_entries_table.php | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 db/migrations/2018_08_30_000000_create_log_entries_table.php (limited to 'db') 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 @@ +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'); + } +} -- cgit v1.2.3-54-g00ecf