Conditions | 1 |
Paths | 1 |
Total Lines | 38 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function template($migrateName) |
||
12 | { |
||
13 | return <<<PHP |
||
14 | <?php |
||
15 | |||
16 | use Wandu\Database\Contracts\ConnectionInterface; |
||
17 | use Wandu\Database\Migrator\Migration; |
||
18 | use Wandu\Database\Query\CreateQuery; |
||
19 | use Wandu\Database\Query\Expression\RawExpression; |
||
20 | |||
21 | class {$migrateName} extends Migration |
||
22 | { |
||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function migrate(ConnectionInterface \$connection) |
||
27 | { |
||
28 | \$connection->query(\$connection->createQueryBuilder('somethings')->create(function (CreateQuery \$table) { |
||
29 | \$table->bigInteger('id')->unsigned()->autoIncrement(); |
||
30 | |||
31 | \$table->timestamp('created_at')->default(new RawExpression('CURRENT_TIMESTAMP')); |
||
32 | \$table->addColumn(new RawExpression('`updated_at` TIMESTAMP DEFAULT now() ON UPDATE now()')); |
||
33 | |||
34 | \$table->primaryKey('id'); |
||
35 | })); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function rollback(ConnectionInterface \$connection) |
||
42 | { |
||
43 | \$connection->query(\$connection->createQueryBuilder('somethings')->drop()); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | PHP; |
||
48 | } |
||
49 | } |
||
50 |