-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajuste la contrainte des unités de matériel dans les événements (#77)
(Sera rollback lorsque l'on prendra en charge les guards lors du switch-back Gestion unitaire => Gestion non unitaire)
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
server/src/database/migrations/20201224140829_changes_material_units_constraint.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
use Phinx\Migration\AbstractMigration; | ||
|
||
class ChangesMaterialUnitsConstraint extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$table = $this->table('event_material_units'); | ||
$table->dropForeignKey('material_unit_id')->save(); | ||
$table | ||
->addForeignKey('material_unit_id', 'material_units', 'id', [ | ||
'delete' => 'CASCADE', | ||
'update' => 'NO_ACTION', | ||
'constraint' => 'fk_event_material_unit_material_unit', | ||
]) | ||
->save(); | ||
} | ||
|
||
public function down() | ||
{ | ||
$table = $this->table('event_material_units'); | ||
$table->dropForeignKey('material_unit_id')->save(); | ||
$table | ||
->addForeignKey('material_unit_id', 'material_units', 'id', [ | ||
'delete' => 'RESTRICT', | ||
'update' => 'NO_ACTION', | ||
'constraint' => 'fk_event_material_unit_material_unit', | ||
]) | ||
->save(); | ||
} | ||
} |