1 from dmigrations
.mysql
import migrations
as m
3 migration
= m
.Migration(sql_up
=["""
4 CREATE TABLE `words_word` (
5 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
6 `word` varchar(100) NOT NULL,
7 `language` varchar(20) NOT NULL,
8 `forms` longtext NOT NULL,
9 `created_on` datetime NOT NULL,
10 `not_a_word` bool NOT NULL,
11 `not_a_word_marked_on` datetime NULL
12 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
15 CREATE TABLE `words_meaning` (
16 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
17 `word_id` integer NOT NULL,
18 `meaning` longtext NOT NULL,
19 `usage` longtext NOT NULL,
20 `language` varchar(20) NOT NULL,
21 `pol` varchar(20) NOT NULL,
22 `created_on` datetime NOT NULL,
23 `is_deleted` bool NOT NULL,
24 `deleted_on` datetime NULL
25 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
28 ALTER TABLE `words_meaning` ADD CONSTRAINT word_id_refs_id_36e13b73 FOREIGN KEY (`word_id`) REFERENCES `words_word` (`id`);
30 CREATE TABLE `words_pronunciation` (
31 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
32 `spelling` varchar(100) NOT NULL,
33 `pronunciation_key` varchar(100) NOT NULL,
34 `created_on` datetime NOT NULL,
35 `is_deleted` bool NOT NULL,
36 `deleted_on` datetime NULL
37 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
40 CREATE TABLE `words_etymology` (
41 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
42 `word_id` integer NOT NULL,
43 `text` longtext NOT NULL,
44 `language` varchar(20) NOT NULL,
45 UNIQUE (`word_id`, `language`)
46 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
49 ALTER TABLE `words_etymology` ADD CONSTRAINT word_id_refs_id_6367a4d3 FOREIGN KEY (`word_id`) REFERENCES `words_word` (`id`);
51 CREATE TABLE `words_short` (
52 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
53 `word_id` integer NOT NULL,
54 `text` varchar(50) NOT NULL,
55 `language` varchar(20) NOT NULL,
56 UNIQUE (`word_id`, `language`)
57 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
60 ALTER TABLE `words_short` ADD CONSTRAINT word_id_refs_id_172d9be4 FOREIGN KEY (`word_id`) REFERENCES `words_word` (`id`);
62 CREATE TABLE `words_changesheet` (
63 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
64 `word_id` integer NOT NULL,
65 `type` varchar(50) NOT NULL,
67 `data` longtext NOT NULL,
68 `user_id` integer NOT NULL,
69 `created_on` datetime NOT NULL
70 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
73 ALTER TABLE `words_changesheet` ADD CONSTRAINT word_id_refs_id_6ca3505f FOREIGN KEY (`word_id`) REFERENCES `words_word` (`id`);
75 CREATE TABLE `words_word_synonyms` (
76 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
77 `from_word_id` integer NOT NULL,
78 `to_word_id` integer NOT NULL,
79 UNIQUE (`from_word_id`, `to_word_id`)
80 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
83 ALTER TABLE `words_word_synonyms` ADD CONSTRAINT from_word_id_refs_id_7b61f267 FOREIGN KEY (`from_word_id`) REFERENCES `words_word` (`id`);
85 ALTER TABLE `words_word_synonyms` ADD CONSTRAINT to_word_id_refs_id_7b61f267 FOREIGN KEY (`to_word_id`) REFERENCES `words_word` (`id`);
87 CREATE TABLE `words_word_thesaurus` (
88 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
89 `from_word_id` integer NOT NULL,
90 `to_word_id` integer NOT NULL,
91 UNIQUE (`from_word_id`, `to_word_id`)
92 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
95 ALTER TABLE `words_word_thesaurus` ADD CONSTRAINT from_word_id_refs_id_4f11e954 FOREIGN KEY (`from_word_id`) REFERENCES `words_word` (`id`);
97 ALTER TABLE `words_word_thesaurus` ADD CONSTRAINT to_word_id_refs_id_4f11e954 FOREIGN KEY (`to_word_id`) REFERENCES `words_word` (`id`);
99 CREATE TABLE `words_word_antonyms` (
100 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
101 `from_word_id` integer NOT NULL,
102 `to_word_id` integer NOT NULL,
103 UNIQUE (`from_word_id`, `to_word_id`)
104 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
107 ALTER TABLE `words_word_antonyms` ADD CONSTRAINT from_word_id_refs_id_37cc738 FOREIGN KEY (`from_word_id`) REFERENCES `words_word` (`id`);
109 ALTER TABLE `words_word_antonyms` ADD CONSTRAINT to_word_id_refs_id_37cc738 FOREIGN KEY (`to_word_id`) REFERENCES `words_word` (`id`);
111 CREATE TABLE `words_word_translations` (
112 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
113 `from_word_id` integer NOT NULL,
114 `to_word_id` integer NOT NULL,
115 UNIQUE (`from_word_id`, `to_word_id`)
116 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
119 ALTER TABLE `words_word_translations` ADD CONSTRAINT from_word_id_refs_id_2ec7430d FOREIGN KEY (`from_word_id`) REFERENCES `words_word` (`id`);
121 ALTER TABLE `words_word_translations` ADD CONSTRAINT to_word_id_refs_id_2ec7430d FOREIGN KEY (`to_word_id`) REFERENCES `words_word` (`id`);
123 CREATE TABLE `words_word_rhymes` (
124 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
125 `from_word_id` integer NOT NULL,
126 `to_word_id` integer NOT NULL,
127 UNIQUE (`from_word_id`, `to_word_id`)
128 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
131 ALTER TABLE `words_word_rhymes` ADD CONSTRAINT from_word_id_refs_id_3eb1d69 FOREIGN KEY (`from_word_id`) REFERENCES `words_word` (`id`);
133 ALTER TABLE `words_word_rhymes` ADD CONSTRAINT to_word_id_refs_id_3eb1d69 FOREIGN KEY (`to_word_id`) REFERENCES `words_word` (`id`);
135 CREATE TABLE `words_word_relateds` (
136 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
137 `from_word_id` integer NOT NULL,
138 `to_word_id` integer NOT NULL,
139 UNIQUE (`from_word_id`, `to_word_id`)
140 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
143 ALTER TABLE `words_word_relateds` ADD CONSTRAINT from_word_id_refs_id_1d5c3a5 FOREIGN KEY (`from_word_id`) REFERENCES `words_word` (`id`);
145 ALTER TABLE `words_word_relateds` ADD CONSTRAINT to_word_id_refs_id_1d5c3a5 FOREIGN KEY (`to_word_id`) REFERENCES `words_word` (`id`);
147 -- The following references should be added but depend on non-existent tables:
149 -- ALTER TABLE `words_changesheet` ADD CONSTRAINT user_id_refs_id_19c4841e FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
151 DROP TABLE `words_word_relateds`;
153 DROP TABLE `words_word_rhymes`;
155 DROP TABLE `words_word_translations`;
157 DROP TABLE `words_word_antonyms`;
159 DROP TABLE `words_word_thesaurus`;
161 DROP TABLE `words_word_synonyms`;
163 DROP TABLE `words_changesheet`;
165 DROP TABLE `words_short`;
167 DROP TABLE `words_etymology`;
169 DROP TABLE `words_pronunciation`;
171 DROP TABLE `words_meaning`;
173 DROP TABLE `words_word`;