summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-31 01:55:05 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-31 03:24:54 +0200
commitac48332166ce28fcb1a2fc130c7f5adbc760e42d (patch)
tree1ff076a6a1c5a35b4ad73477d60cbcb77ebfd922 /db
parent9d9aa71eb736885f23c069a75c7a047b06434178 (diff)
Models: Added LogEntry model
Diffstat (limited to 'db')
-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');
+ }
+}