2 PG_MIGRATION_QUERY = """
\r
3 SELECT id AS user_ptr_id, is_approved, email_isvalid, email_key, reputation, gravatar, gold, silver, bronze, questions_per_page, last_seen, real_name, website, location, date_of_birth, about, hide_ignored_questions, tag_filter_setting INTO forum_user FROM auth_user;
\r
5 ALTER TABLE forum_user
\r
6 ADD CONSTRAINT forum_user_pkey PRIMARY KEY(user_ptr_id);
\r
8 ALTER TABLE forum_user
\r
9 ADD CONSTRAINT forum_user_user_ptr_id_fkey FOREIGN KEY (user_ptr_id)
\r
10 REFERENCES auth_user (id) MATCH SIMPLE
\r
11 ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
13 ALTER TABLE forum_user
\r
14 ADD CONSTRAINT forum_user_reputation_check CHECK (reputation >= 0);
\r
16 ALTER TABLE auth_user DROP COLUMN is_approved;
\r
17 ALTER TABLE auth_user DROP COLUMN email_isvalid;
\r
18 ALTER TABLE auth_user DROP COLUMN email_key;
\r
19 ALTER TABLE auth_user DROP COLUMN reputation;
\r
20 ALTER TABLE auth_user DROP COLUMN gravatar;
\r
21 ALTER TABLE auth_user DROP COLUMN gold;
\r
22 ALTER TABLE auth_user DROP COLUMN silver;
\r
23 ALTER TABLE auth_user DROP COLUMN bronze;
\r
24 ALTER TABLE auth_user DROP COLUMN questions_per_page;
\r
25 ALTER TABLE auth_user DROP COLUMN last_seen;
\r
26 ALTER TABLE auth_user DROP COLUMN real_name;
\r
27 ALTER TABLE auth_user DROP COLUMN website;
\r
28 ALTER TABLE auth_user DROP COLUMN "location";
\r
29 ALTER TABLE auth_user DROP COLUMN date_of_birth;
\r
30 ALTER TABLE auth_user DROP COLUMN about;
\r
31 ALTER TABLE auth_user DROP COLUMN hide_ignored_questions;
\r
32 ALTER TABLE auth_user DROP COLUMN tag_filter_setting;
\r
36 PG_FKEYS_QUERY = """
\r
38 ALTER TABLE "public"."activity"
\r
39 DROP CONSTRAINT "activity_user_id_fkey",
\r
40 ADD CONSTRAINT "activity_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
42 ALTER TABLE "public"."answer"
\r
43 DROP CONSTRAINT "answer_author_id_fkey",
\r
44 ADD CONSTRAINT "answer_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
45 DROP CONSTRAINT "answer_deleted_by_id_fkey",
\r
46 ADD CONSTRAINT "answer_deleted_by_id_fkey" FOREIGN KEY ("deleted_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
47 DROP CONSTRAINT "answer_last_edited_by_id_fkey",
\r
48 ADD CONSTRAINT "answer_last_edited_by_id_fkey" FOREIGN KEY ("last_edited_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
49 DROP CONSTRAINT "answer_locked_by_id_fkey",
\r
50 ADD CONSTRAINT "answer_locked_by_id_fkey" FOREIGN KEY ("locked_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
52 ALTER TABLE "public"."answer_revision"
\r
53 DROP CONSTRAINT "answer_revision_author_id_fkey",
\r
54 ADD CONSTRAINT "answer_revision_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
56 ALTER TABLE "public"."award"
\r
57 DROP CONSTRAINT "award_user_id_fkey",
\r
58 ADD CONSTRAINT "award_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
60 ALTER TABLE "public"."comment"
\r
61 DROP CONSTRAINT "comment_user_id_fkey",
\r
62 ADD CONSTRAINT "comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
64 ALTER TABLE "public"."favorite_question"
\r
65 DROP CONSTRAINT "favorite_question_user_id_fkey",
\r
66 ADD CONSTRAINT "favorite_question_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
68 ALTER TABLE "public"."flagged_item"
\r
69 DROP CONSTRAINT "flagged_item_user_id_fkey",
\r
70 ADD CONSTRAINT "flagged_item_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
72 ALTER TABLE "public"."forum_anonymousanswer"
\r
73 DROP CONSTRAINT "forum_anonymousanswer_author_id_fkey",
\r
74 ADD CONSTRAINT "forum_anonymousanswer_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
76 ALTER TABLE "public"."forum_anonymousquestion"
\r
77 DROP CONSTRAINT "forum_anonymousquestion_author_id_fkey",
\r
78 ADD CONSTRAINT "forum_anonymousquestion_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
80 ALTER TABLE "public"."forum_authkeyuserassociation"
\r
81 DROP CONSTRAINT "forum_authkeyuserassociation_user_id_fkey",
\r
82 ADD CONSTRAINT "forum_authkeyuserassociation_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
84 ALTER TABLE "public"."forum_markedtag"
\r
85 DROP CONSTRAINT "forum_markedtag_user_id_fkey",
\r
86 ADD CONSTRAINT "forum_markedtag_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
88 ALTER TABLE "public"."forum_questionsubscription"
\r
89 DROP CONSTRAINT "forum_questionsubscription_user_id_fkey",
\r
90 ADD CONSTRAINT "forum_questionsubscription_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
92 ALTER TABLE "public"."forum_subscriptionsettings"
\r
93 DROP CONSTRAINT "forum_subscriptionsettings_user_id_fkey",
\r
94 ADD CONSTRAINT "forum_subscriptionsettings_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
96 ALTER TABLE "public"."forum_validationhash"
\r
97 DROP CONSTRAINT "forum_validationhash_user_id_fkey",
\r
98 ADD CONSTRAINT "forum_validationhash_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
100 ALTER TABLE "public"."question"
\r
101 DROP CONSTRAINT "question_author_id_fkey",
\r
102 ADD CONSTRAINT "question_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
103 DROP CONSTRAINT "question_closed_by_id_fkey",
\r
104 ADD CONSTRAINT "question_closed_by_id_fkey" FOREIGN KEY ("closed_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
105 DROP CONSTRAINT "question_deleted_by_id_fkey",
\r
106 ADD CONSTRAINT "question_deleted_by_id_fkey" FOREIGN KEY ("deleted_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
107 DROP CONSTRAINT "question_last_activity_by_id_fkey",
\r
108 ADD CONSTRAINT "question_last_activity_by_id_fkey" FOREIGN KEY ("last_activity_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
109 DROP CONSTRAINT "question_last_edited_by_id_fkey",
\r
110 ADD CONSTRAINT "question_last_edited_by_id_fkey" FOREIGN KEY ("last_edited_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
111 DROP CONSTRAINT "question_locked_by_id_fkey",
\r
112 ADD CONSTRAINT "question_locked_by_id_fkey" FOREIGN KEY ("locked_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
114 ALTER TABLE "public"."question_followed_by"
\r
115 DROP CONSTRAINT "question_followed_by_user_id_fkey",
\r
116 ADD CONSTRAINT "question_followed_by_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
118 ALTER TABLE "public"."question_revision"
\r
119 DROP CONSTRAINT "question_revision_author_id_fkey",
\r
120 ADD CONSTRAINT "question_revision_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
122 ALTER TABLE "public"."repute"
\r
123 DROP CONSTRAINT "repute_user_id_fkey",
\r
124 ADD CONSTRAINT "repute_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
126 ALTER TABLE "public"."tag"
\r
127 DROP CONSTRAINT "tag_created_by_id_fkey",
\r
128 ADD CONSTRAINT "tag_created_by_id_fkey" FOREIGN KEY ("created_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED,
\r
129 DROP CONSTRAINT "tag_deleted_by_id_fkey",
\r
130 ADD CONSTRAINT "tag_deleted_by_id_fkey" FOREIGN KEY ("deleted_by_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
132 ALTER TABLE "public"."vote"
\r
133 DROP CONSTRAINT "vote_user_id_fkey",
\r
134 ADD CONSTRAINT "vote_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."forum_user" (user_ptr_id) ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
\r
138 MYSQL_MIGRATION_QUERY = """
\r
139 CREATE TABLE `forum_user` (
\r
140 `user_ptr_id` int(11) NOT NULL,
\r
141 `is_approved` tinyint(1) NOT NULL,
\r
142 `email_isvalid` tinyint(1) NOT NULL,
\r
143 `email_key` varchar(32) DEFAULT NULL,
\r
144 `reputation` int(10) unsigned NOT NULL,
\r
145 `gravatar` varchar(32) NOT NULL,
\r
146 `gold` smallint(6) NOT NULL,
\r
147 `silver` smallint(6) NOT NULL,
\r
148 `bronze` smallint(6) NOT NULL,
\r
149 `questions_per_page` smallint(6) NOT NULL,
\r
150 `last_seen` datetime NOT NULL,
\r
151 `real_name` varchar(100) NOT NULL,
\r
152 `website` varchar(200) NOT NULL,
\r
153 `location` varchar(100) NOT NULL,
\r
154 `date_of_birth` date DEFAULT NULL,
\r
155 `about` longtext NOT NULL,
\r
156 `hide_ignored_questions` tinyint(1) NOT NULL,
\r
157 `tag_filter_setting` varchar(16) NOT NULL,
\r
158 PRIMARY KEY (`user_ptr_id`),
\r
159 CONSTRAINT `user_ptr_id_refs_id_71071d7` FOREIGN KEY (`user_ptr_id`) REFERENCES `auth_user` (`id`)
\r
160 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
\r
161 SELECT id AS user_ptr_id, is_approved, email_isvalid, email_key, reputation, gravatar, gold, silver, bronze, questions_per_page,
\r
162 last_seen, real_name, website, location, date_of_birth, about, hide_ignored_questions, tag_filter_setting FROM auth_user;
\r
164 ALTER TABLE `auth_user`
\r
165 DROP COLUMN `is_approved`,
\r
166 DROP COLUMN `email_isvalid`,
\r
167 DROP COLUMN `email_key`,
\r
168 DROP COLUMN `reputation`,
\r
169 DROP COLUMN `gravatar`,
\r
170 DROP COLUMN `gold`,
\r
171 DROP COLUMN `silver`,
\r
172 DROP COLUMN `bronze`,
\r
173 DROP COLUMN `questions_per_page`,
\r
174 DROP COLUMN `last_seen`,
\r
175 DROP COLUMN `real_name`,
\r
176 DROP COLUMN `website`,
\r
177 DROP COLUMN `location`,
\r
178 DROP COLUMN `date_of_birth`,
\r
179 DROP COLUMN `about`,
\r
180 DROP COLUMN `hide_ignored_questions`,
\r
181 DROP COLUMN `tag_filter_setting`;
\r
185 MYSQL_FKEYS_QUERY = """
\r
187 ALTER TABLE `activity` DROP FOREIGN KEY `user_id_refs_id_47c8583f`;
\r
188 ALTER TABLE `activity` ADD CONSTRAINT `user_id_refs_user_ptr_id_62ae9785` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
190 ALTER TABLE `answer` DROP FOREIGN KEY `author_id_refs_id_192b0170`;
\r
191 ALTER TABLE `answer` ADD CONSTRAINT `author_id_refs_user_ptr_id_9681994` FOREIGN KEY (`author_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
192 ALTER TABLE `answer` DROP FOREIGN KEY `deleted_by_id_refs_id_192b0170`;
\r
193 ALTER TABLE `answer` ADD CONSTRAINT `deleted_by_id_refs_user_ptr_id_9681994` FOREIGN KEY (`deleted_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
194 ALTER TABLE `answer` DROP FOREIGN KEY `last_edited_by_id_refs_id_192b0170`;
\r
195 ALTER TABLE `answer` ADD CONSTRAINT `last_edited_by_id_refs_user_ptr_id_9681994` FOREIGN KEY (`last_edited_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
196 ALTER TABLE `answer` DROP FOREIGN KEY `locked_by_id_refs_id_192b0170`;
\r
197 ALTER TABLE `answer` ADD CONSTRAINT `locked_by_id_refs_user_ptr_id_9681994` FOREIGN KEY (`locked_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
199 ALTER TABLE `answer_revision` DROP FOREIGN KEY `author_id_refs_id_3ccc055f`;
\r
200 ALTER TABLE `answer_revision` ADD CONSTRAINT `author_id_refs_user_ptr_id_331f0123` FOREIGN KEY (`author_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
202 ALTER TABLE `award` DROP FOREIGN KEY `user_id_refs_id_2d83e9b6`;
\r
203 ALTER TABLE `award` ADD CONSTRAINT `user_id_refs_user_ptr_id_1b2d0192` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
205 ALTER TABLE `comment` DROP FOREIGN KEY `user_id_refs_id_6be725e8`;
\r
206 ALTER TABLE `comment` ADD CONSTRAINT `user_id_refs_user_ptr_id_1ac2320c` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
208 ALTER TABLE `favorite_question` DROP FOREIGN KEY `user_id_refs_id_52853822`;
\r
209 ALTER TABLE `favorite_question` ADD CONSTRAINT `user_id_refs_user_ptr_id_3f419c1a` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
211 ALTER TABLE `flagged_item` DROP FOREIGN KEY `user_id_refs_id_35e3c608`;
\r
212 ALTER TABLE `flagged_item` ADD CONSTRAINT `user_id_refs_user_ptr_id_1ce834d4` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
214 ALTER TABLE `forum_anonymousanswer` DROP FOREIGN KEY `author_id_refs_id_13fb542e`;
\r
215 ALTER TABLE `forum_anonymousanswer` ADD CONSTRAINT `author_id_refs_user_ptr_id_6b5b476a` FOREIGN KEY (`author_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
217 ALTER TABLE `forum_anonymousquestion` DROP FOREIGN KEY `author_id_refs_id_7511a98a`;
\r
218 ALTER TABLE `forum_anonymousquestion` ADD CONSTRAINT `author_id_refs_user_ptr_id_104edd52` FOREIGN KEY (`author_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
220 ALTER TABLE `forum_authkeyuserassociation` DROP FOREIGN KEY `user_id_refs_id_2c2a6b01`;
\r
221 ALTER TABLE `forum_authkeyuserassociation` ADD CONSTRAINT `user_id_refs_user_ptr_id_3f0ec0c3` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
223 ALTER TABLE `forum_markedtag` DROP FOREIGN KEY `user_id_refs_id_23b833bd`;
\r
224 ALTER TABLE `forum_markedtag` ADD CONSTRAINT `user_id_refs_user_ptr_id_5a13f081` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
226 ALTER TABLE `forum_questionsubscription` DROP FOREIGN KEY `user_id_refs_id_18e1489`;
\r
227 ALTER TABLE `forum_questionsubscription` ADD CONSTRAINT `user_id_refs_user_ptr_id_521b19ad` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
229 ALTER TABLE `forum_subscriptionsettings` DROP FOREIGN KEY `user_id_refs_id_35edacb4`;
\r
230 ALTER TABLE `forum_subscriptionsettings` ADD CONSTRAINT `user_id_refs_user_ptr_id_1bc4fc70` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
232 ALTER TABLE `forum_validationhash` DROP FOREIGN KEY `user_id_refs_id_2c2d214b`;
\r
233 ALTER TABLE `forum_validationhash` ADD CONSTRAINT `user_id_refs_user_ptr_id_4e5b2d6f` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
235 ALTER TABLE `question` DROP FOREIGN KEY `author_id_refs_id_56e9d00c`;
\r
236 ALTER TABLE `question` ADD CONSTRAINT `author_id_refs_user_ptr_id_60d41818` FOREIGN KEY (`author_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
237 ALTER TABLE `question` DROP FOREIGN KEY `closed_by_id_refs_id_56e9d00c`;
\r
238 ALTER TABLE `question` ADD CONSTRAINT `closed_by_id_refs_user_ptr_id_60d41818` FOREIGN KEY (`closed_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
239 ALTER TABLE `question` DROP FOREIGN KEY `deleted_by_id_refs_id_56e9d00c`;
\r
240 ALTER TABLE `question` ADD CONSTRAINT `deleted_by_id_refs_user_ptr_id_60d41818` FOREIGN KEY (`deleted_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
241 ALTER TABLE `question` DROP FOREIGN KEY `last_activity_by_id_refs_id_56e9d00c`;
\r
242 ALTER TABLE `question` ADD CONSTRAINT `last_activity_by_id_refs_user_ptr_id_60d41818` FOREIGN KEY (`last_activity_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
243 ALTER TABLE `question` DROP FOREIGN KEY `last_edited_by_id_refs_id_56e9d00c`;
\r
244 ALTER TABLE `question` ADD CONSTRAINT `last_edited_by_id_refs_user_ptr_id_60d41818` FOREIGN KEY (`last_edited_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
245 ALTER TABLE `question` DROP FOREIGN KEY `locked_by_id_refs_id_56e9d00c`;
\r
246 ALTER TABLE `question` ADD CONSTRAINT `locked_by_id_refs_user_ptr_id_60d41818` FOREIGN KEY (`locked_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
248 ALTER TABLE `question_followed_by` DROP FOREIGN KEY `user_id_refs_id_6d30712d`;
\r
249 ALTER TABLE `question_followed_by` ADD CONSTRAINT `user_id_refs_user_ptr_id_615e65af` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
251 ALTER TABLE `question_revision` DROP FOREIGN KEY `author_id_refs_id_4f88024f`;
\r
252 ALTER TABLE `question_revision` ADD CONSTRAINT `author_id_refs_user_ptr_id_42e3d48d` FOREIGN KEY (`author_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
254 ALTER TABLE `repute` DROP FOREIGN KEY `user_id_refs_id_5a426cd`;
\r
255 ALTER TABLE `repute` ADD CONSTRAINT `user_id_refs_user_ptr_id_5ea9540f` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
257 ALTER TABLE `tag` DROP FOREIGN KEY `created_by_id_refs_id_47205d6d`;
\r
258 ALTER TABLE `tag` ADD CONSTRAINT `created_by_id_refs_user_ptr_id_417f3449` FOREIGN KEY (`created_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
259 ALTER TABLE `tag` DROP FOREIGN KEY `deleted_by_id_refs_id_47205d6d`;
\r
260 ALTER TABLE `tag` ADD CONSTRAINT `deleted_by_id_refs_user_ptr_id_417f3449` FOREIGN KEY (`deleted_by_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
262 ALTER TABLE `vote` DROP FOREIGN KEY `user_id_refs_id_760a4df0`;
\r
263 ALTER TABLE `vote` ADD CONSTRAINT `user_id_refs_user_ptr_id_18723e34` FOREIGN KEY (`user_id`) REFERENCES `forum_user` (`user_ptr_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
\r
267 from django.core.management.base import NoArgsCommand
\r
268 from django.db import connection, transaction
\r
269 from django.conf import settings
\r
271 class Command(NoArgsCommand):
\r
272 def handle_noargs(self, **options):
\r
273 if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ):
\r
274 migration_query = PG_MIGRATION_QUERY
\r
275 fkeys_query = PG_FKEYS_QUERY
\r
276 elif settings.DATABASE_ENGINE == 'mysql':
\r
277 migration_query = MYSQL_MIGRATION_QUERY
\r
278 fkeys_query = MYSQL_FKEYS_QUERY
\r
280 raise Exception("Database backend not suported by this migration command")
\r
282 cursor = connection.cursor()
\r
283 cursor.execute(migration_query)
\r
284 cursor.execute(fkeys_query)
\r
285 transaction.commit_unless_managed()