-- Deploy gaia:2020_02_20_add_word_and_synonymgroup to mysql

BEGIN;
--
-- Create model SynonymGroup
--
CREATE TABLE `api_synonymgroup` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `created_time` datetime(6) NOT NULL, `updated_time` datetime(6) NOT NULL);
--
-- Create model Word
--
CREATE TABLE `api_word` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `text` varchar(50) NOT NULL UNIQUE);
--
-- Add field words to synonymgroup
--
CREATE TABLE `api_synonymgroup_word` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `synonymgroup_id` integer NOT NULL, `word_id` integer NOT NULL);
CREATE INDEX `api_word_text_6f0fe58a` ON `api_word` (`text`);
ALTER TABLE `api_synonymgroup_word` ADD CONSTRAINT `api_synonymgroup_wor_synonymgroup_id_2087ab5c_fk_api_synon` FOREIGN KEY (`synonymgroup_id`) REFERENCES `api_synonymgroup` (`id`);
ALTER TABLE `api_synonymgroup_word` ADD CONSTRAINT `api_synonymgroup_word_word_id_efee6324_fk_api_word_id` FOREIGN KEY (`word_id`) REFERENCES `api_word` (`id`);
ALTER TABLE `api_synonymgroup_word` ADD CONSTRAINT `api_synonymgroup_word_synonymgroup_id_word_id_12853fbb_uniq` UNIQUE (`synonymgroup_id`, `word_id`);

COMMIT;
