Skip to content

Commit

Permalink
Drop forms_tags table
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed May 25, 2017
1 parent bfae9aa commit 96fc128
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
13 changes: 0 additions & 13 deletions migrations/20170328080656_add_forms_tags_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,5 @@ public function change()
])
->create();
}

/**
* Migrate Up.
*/
public function up()
{
}

/**
* Migrate Down.
*/
public function down()
{
}
}
51 changes: 51 additions & 0 deletions migrations/20170525003110_drop_forms_tags_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,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->dropTable('forms_tags');
}

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();
}
}

0 comments on commit 96fc128

Please sign in to comment.