diff --git a/Config/Migration/1769652195_add_index.php b/Config/Migration/1769652195_add_index.php new file mode 100644 index 0000000..a0fa47a --- /dev/null +++ b/Config/Migration/1769652195_add_index.php @@ -0,0 +1,63 @@ + array( + 'create_field' => array( + 'tags' => array( + 'indexes' => array( + 'idx1_p_tags' => array('column' => array('model', 'block_id'), 'unique' => 0), + ), + ), + 'tags_contents' => array( + 'indexes' => array( + 'idx1_p_tags_contents' => array('column' => array('tag_id'), 'unique' => 0), + ), + ), + ), + ), + 'down' => array( + 'drop_field' => array( + 'tags' => array('indexes' => array('idx1_p_tags')), + 'tags_contents' => array('indexes' => array('idx1_p_tags_contents')), + ), + ), + ); + +/** + * Before migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function before($direction) { + return true; + } + +/** + * After migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function after($direction) { + return true; + } +} diff --git a/Config/Schema/schema.php b/Config/Schema/schema.php index 0818b20..12702b9 100644 --- a/Config/Schema/schema.php +++ b/Config/Schema/schema.php @@ -52,7 +52,8 @@ public function after($event = array()) { 'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false, 'comment' => '更新者'), 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '更新日時'), 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) + 'PRIMARY' => array('column' => 'id', 'unique' => 1), + 'idx1_p_tags' => array('column' => array('model', 'block_id'), 'unique' => 0) ), 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB') ); @@ -71,7 +72,8 @@ public function after($event = array()) { 'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '更新日時'), 'indexes' => array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'model' => array('column' => array('model', 'content_id'), 'unique' => 0) + 'model' => array('column' => array('model', 'content_id'), 'unique' => 0), + 'idx1_p_tags_contents' => array('column' => array('tag_id'), 'unique' => 0) ), 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB') );