1 | BEGIN;
|
---|
2 | CREATE TABLE `polls_poll` (
|
---|
3 | `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
---|
4 | `question` varchar(200) NOT NULL,
|
---|
5 | `pub_date` datetime NOT NULL
|
---|
6 | )
|
---|
7 | ;
|
---|
8 | CREATE TABLE `polls_choice` (
|
---|
9 | `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
---|
10 | `poll_id` integer NOT NULL,
|
---|
11 | `choice` varchar(200) NOT NULL,
|
---|
12 | `votes` integer NOT NULL
|
---|
13 | )
|
---|
14 | ;
|
---|
15 | ALTER TABLE `polls_choice` ADD CONSTRAINT poll_id_refs_id_5d896c23 FOREIGN KEY (`poll_id`) REFERENCES `polls_poll` (`id`);
|
---|
16 | CREATE INDEX `polls_choice_poll_id` ON `polls_choice` (`poll_id`);
|
---|
17 | COMMIT;
|
---|