summaryrefslogtreecommitdiff
path: root/db/migrations/2018_08_30_000000_create_log_entries_table.php
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations/2018_08_30_000000_create_log_entries_table.php')
-rw-r--r--db/migrations/2018_08_30_000000_create_log_entries_table.php47
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');
+ }
+}