Skip to content

Commit

Permalink
速度改善のための修正
Browse files Browse the repository at this point in the history
・インデックスの付与
  • Loading branch information
s-nakajima committed May 9, 2018
1 parent eebc888 commit 70c78e0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
79 changes: 79 additions & 0 deletions Config/Migration/1525658863_for_speed_up_2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* 速度改善のためのインデックス見直し
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/

App::uses('NetCommonsMigration', 'NetCommons.Config/Migration');

/**
* 速度改善のためのインデックス見直し
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\Rooms\Config\Migration
*/
class ForSpeedUp2 extends NetCommonsMigration {

/**
* Migration description
*
* @var string
*/
public $description = 'for_speed_up_2';

/**
* Actions to be performed
*
* @var array $migration
*/
public $migration = array(
'up' => array(
'alter_field' => array(
'spaces' => array(
'permalink' => array('type' => 'string', 'null' => false, 'default' => null, 'key' => 'index', 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
),
'create_field' => array(
'spaces' => array(
'indexes' => array(
'permalink' => array('column' => array('permalink', 'id'), 'unique' => 0),
),
),
),
),
'down' => array(
'alter_field' => array(
'spaces' => array(
'permalink' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
),
'drop_field' => array(
'spaces' => array('indexes' => array('permalink')),
),
),
);

/**
* 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;
}
}
5 changes: 3 additions & 2 deletions Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,16 @@ public function after($event = array()) {
'room_disk_size' => array('type' => 'biginteger', 'null' => true, 'default' => null, 'unsigned' => false, 'comment' => '各ルームの容量。NULLの場合、無制限。'),
'room_id_root' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
'page_id_top' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
'permalink' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'permalink' => array('type' => 'string', 'null' => false, 'default' => null, 'key' => 'index', 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'is_m17n' => array('type' => 'boolean', 'null' => true, 'default' => '0'),
'after_user_save_model' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1)
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'permalink' => array('column' => array('permalink', 'id'), 'unique' => 0)
),
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
);
Expand Down

0 comments on commit 70c78e0

Please sign in to comment.