Skip to content

Commit df01ced

Browse files
authored
add-migration (#807)
1 parent 823d673 commit df01ced

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Phinx\Migration\AbstractMigration;
4+
5+
class AddSourceBoxFkToStockTable extends AbstractMigration
6+
{
7+
public function up(): void
8+
{
9+
$this->table('stock')->addColumn('source_box_id', 'integer', [
10+
'null' => true,
11+
'signed' => false,
12+
'after' => 'box_state_id',
13+
])
14+
->addForeignKey('source_box_id', 'stock', 'id', [
15+
'delete' => 'SET_NULL', 'update' => 'CASCADE',
16+
])
17+
->save()
18+
;
19+
}
20+
21+
public function down(): void
22+
{
23+
$this->table('stock')->dropForeignKey('source_box_id')->save();
24+
$this->table('stock')->removeColumn('source_box_id')->save();
25+
}
26+
}

0 commit comments

Comments
 (0)