Skip to content

Commit

Permalink
Ajoute le champ park_id aux unités de matériel (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Donov4n authored Jan 5, 2021
1 parent 2dc074a commit 8640b5e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
use Phinx\Migration\AbstractMigration;

class AddParkIdInMaterialUnit extends AbstractMigration
{
public function up()
{
$table = $this->table('material_units');
$table
->addColumn('park_id', 'integer', ['after' => 'serial_number'])
->addForeignKey('park_id', 'parks', 'id', [
'delete' => 'CASCADE',
'update' => 'NO_ACTION',
'constraint' => 'fk_material_unit_park',
])
->save();
}

public function down()
{
$table = $this->table('material_units');
$table
->removeColumn('park_id')
->save();
}
}
4 changes: 4 additions & 0 deletions server/tests/Fixtures/seed/material_units.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
{
"id": 1,
"material_id": 6,
"park_id": 1,
"serial_number": "XR18-1",
"is_broken": false
},
{
"id": 2,
"material_id": 6,
"park_id": 1,
"serial_number": "XR18-2",
"is_broken": false
},
{
"id": 3,
"material_id": 6,
"park_id": 2,
"serial_number": "XR18-3",
"is_broken": true
},
{
"id": 4,
"material_id": 7,
"park_id": 2,
"serial_number": "VHCL-1",
"is_broken": false
}
Expand Down

0 comments on commit 8640b5e

Please sign in to comment.