Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
外部キー制約によってMroongaでDROP DATABASEが失敗する例
Table Create Table
contents CREATE TABLE `contents` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `text` text,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
Table Create Table
c_refs CREATE TABLE `c_refs` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `content_id` int(11) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `index_c_refs_on_content_id` (`content_id`),\n CONSTRAINT `content_id` FOREIGN KEY (`content_id`) REFERENCES `contents` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
DROP DATABASE IF EXISTS innodb_test;
CREATE DATABASE innodb_test;
USE innodb_test;
CREATE TABLE contents (
id int PRIMARY KEY AUTO_INCREMENT,
text text
) DEFAULT CHARSET utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE c_refs (
id int PRIMARY KEY AUTO_INCREMENT,
content_id int,
KEY `index_c_refs_on_content_id` (`content_id`),
CONSTRAINT `content_id` FOREIGN KEY (`content_id`) REFERENCES `contents` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) DEFAULT CHARSET utf8mb4 ROW_FORMAT=DYNAMIC;
SHOW CREATE TABLE contents;
SHOW CREATE TABLE c_refs;
DROP DATABASE innodb_test;
Table Create Table
contents CREATE TABLE `contents` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `text` text,\n PRIMARY KEY (`id`),\n FULLTEXT KEY `index_contents_on_text` (`text`)\n) ENGINE=Mroonga DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
Table Create Table
c_refs CREATE TABLE `c_refs` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `content_id` int(11) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `index_c_refs_on_content_id` (`content_id`),\n CONSTRAINT `content_id` FOREIGN KEY (`content_id`) REFERENCES `mroonga_test`.`contents` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) ENGINE=Mroonga DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
ERROR 1016 (HY000) at line 22: [table][remove] a column that references the table exists: <c_refs.content_id> -> <contents>
DROP DATABASE IF EXISTS mroonga_test;
CREATE DATABASE mroonga_test;
USE mroonga_test;
CREATE TABLE contents (
id int PRIMARY KEY AUTO_INCREMENT,
text text,
FULLTEXT KEY `index_contents_on_text` (`text`)
) ENGINE=mroonga DEFAULT CHARSET utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE c_refs (
id int PRIMARY KEY AUTO_INCREMENT,
content_id int,
KEY `index_c_refs_on_content_id` (`content_id`),
CONSTRAINT `content_id` FOREIGN KEY (`content_id`) REFERENCES `contents` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=mroonga DEFAULT CHARSET utf8mb4 ROW_FORMAT=DYNAMIC;
SHOW CREATE TABLE contents;
SHOW CREATE TABLE c_refs;
DROP DATABASE mroonga_test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment