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