-
Notifications
You must be signed in to change notification settings - Fork 503
/
20170525003110_drop_forms_tags_table.php
51 lines (48 loc) · 1.4 KB
/
20170525003110_drop_forms_tags_table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
use Phinx\Migration\AbstractMigration;
class DropFormsTagsTable extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function up()
{
$this->table('forms_tags')->drop()->save();
}
public function down()
{
$this->table('forms_tags', [
'id' => false,
'primary_key' => ['form_id', 'tag_id'],
])
->addColumn('form_id', 'integer')
->addForeignKey('form_id', 'forms', 'id', [
'delete' => 'CASCADE',
'update' => 'CASCADE'
])
->addColumn('tag_id', 'integer')
->addForeignKey('tag_id', 'tags', 'id', [
'delete' => 'CASCADE',
'update' => 'CASCADE'
])
->create();
}
}