1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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');
}
}
|