# エラーが出る $ rails db:migrate Caused by: ActiveRecord::StatementInvalid: Mysql2::Error: Table storage engine for 'table' doesn't have this option: CREATE TABLE `table` (`id` bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` varchar(255) NOT NULL, `type` varchar(255) NOT NULL, `point` int NOT NULL, `after_point` int NOT NULL, `hoge_type` varchar(255) NOT NULL, `hoge_json` text, `created_at` datetime, `updated_at` datetime) ROW_FORMAT=COMPRESSED : # dbの設定を確認する mysql> show variables like "innodb_file%"; +--------------------------+-----------+ | Variable_name | Value | +--------------------------+-----------+ | innodb_file_format | Barracuda | | innodb_file_format_check | ON | | innodb_file_format_max | Barracuda | | innodb_file_per_table | OFF | +--------------------------+-----------+ 4 rows in set (0.00 sec) # innodb_file_per_tableをONにしたい。 mysql> SET GLOBAL innodb_file_per_table=1; # ONになっている mysql> show variables like "innodb_file%"; +--------------------------+-----------+ | Variable_name | Value | +--------------------------+-----------+ | innodb_file_format | Barracuda | | innodb_file_format_check | ON | | innodb_file_format_max | Barracuda | | innodb_file_per_table | ON | +--------------------------+-----------+ 4 rows in set (0.00 sec) $ rails db:migrate =>ROW_FORMAT=COMPRESSEDのオプションがついていても通る。
参考:https://dev.mysql.com/doc/refman/5.6/ja/tablespace-enabling.html
起動時にinnodb_file_per_tableをONにしておく
上記の手順で設定しても、mysqlを起動し直すとinnodb_file_per_tableはOFFに戻る。
これは起動時の設定ファイルが影響している。
なので起動時の設定ファイルの中身も変更しておく。
# etc/my.cnfを確認し編集する $ less /usr/local/etc/my.cnf # Default Homebrew MySQL server config [mysqld] # Only allow connections from localhost bind-address = 127.0.0.1 innodb_file_per_table = OFF innodb_large_prefix=0 # innodb_file_per_table を ONにする $ vi /usr/local/etc/my.cnf innodb_file_per_table = ON
以上。