idint(10)unsignedNOTNULLAUTO_INCREMENT,->usernamevarchar(254)COLLATEutf8mb4_unicode_ciNOTNULL,->">
我尝试将icinga更新到2.9.1版本,并且为此需要在sql数据库上应用迁移。
迁移使用以下sql查询:
2.9.0迁移
CREATE TABLE `icingaweb_rememberme`( -> id int(10) unsigned NOT NULL AUTO_INCREMENT, -> username varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL, -> passphrase varchar(256) NOT NULL, -> random_iv varchar(24) NOT NULL, -> http_user_agent text NOT NULL, -> expires_at timestamp NULL DEFAULT NULL, -> ctime timestamp NULL DEFAULT NULL, -> mtime timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, -> PRIMARY KEY (id) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
2.9.1迁移
ALTER TABLE `icingaweb_rememberme` -> MODIFY random_iv varchar(32) NOT NULL;
问题是,当我尝试执行时,我得到了冲突的错误消息
完整的迁移日志
MariaDB [(none)]> use icingaweb2 Database changed MariaDB [icingaweb2]> CREATE TABLE `icingaweb_rememberme`( -> id int(10) unsigned NOT NULL AUTO_INCREMENT, -> username varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL, -> passphrase varchar(256) NOT NULL, -> random_iv varchar(24) NOT NULL, -> http_user_agent text NOT NULL, -> expires_at timestamp NULL DEFAULT NULL, -> ctime timestamp NULL DEFAULT NULL, -> mtime timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, -> PRIMARY KEY (id) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; ERROR 1050 (42S01): 表'icingaweb_rememberme'已经存在 MariaDB [icingaweb2]> ALTER TABLE `icingaweb_rememberme` -> MODIFY random_iv varchar(32) NOT NULL; ERROR 1932 (42S02): 表'icingaweb2.icingaweb_rememberme'在引擎中不存在
Icinga当前显示此错误(类似于第二个迁移错误)
SQLSTATE[42S02]: 基表或视图不存在:1932 表'icingaweb2.icingaweb_rememberme'在引擎中不存在
问题
我如何应用迁移,以便集合icingaweb2
具有表icingaweb_rememberme
I found the anwser.
MySQL database created a file named
icingaweb_rememberme.idb
, but there is no correspondingfrm
file.I have deleted the
icingaweb_rememberme
table, removed the remaining.idb
files in the MySQL directory, and re-created the table with a single command (having applied the secondary migration).This may not be the complete answer, or there may be a simpler solution, but for me this worked.
If you plan to delete or remove files and tables, remember to back them up