看一看

BEGIN;
CREATE TABLE "poll_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL);
CREATE TABLE "poll_question" ("id" integer NOT NULL PRIMARY KEY AUTO_INCREMENT, "question_text" varchar(200) NOT NULL);
CREATE TABLE poll_choice__new (id integer NOT NULL PRIMARY KEY AUTO_INCREMENT, choice_text varchar(200) NOT NULL, votes integer NOT NULL, question_id integer NOT NULL REFERENCES poll_question (id));
INSERT INTO poll_choice__new (votes, choice_text, question_id, id) SELECT votes, choice_text, NULL, id FROM poll_choice;
DROP TABLE "poll_choice";
ALTER TABLE "poll_choice__new" RENAME TO "poll_choice";
CREATE INDEX "poll_choice_7aa0f6ee" ON "poll_choice" ("question_id");

COMMIT;


BEGIN;
CREATE TABLE `blog_article` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `title` varchar(50) NOT NULL, `content` longtext NOT NULL, `score` integer NOT NULL);
CREATE TABLE `blog_author` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL, `qq` varchar(10) NOT NULL, `addr` longtext NOT NULL, `email` varchar(254) NOT NULL);
CREATE TABLE `blog_tag` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL);
ALTER TABLE `blog_article` ADD COLUMN `author_id` integer NOT NULL;
ALTER TABLE `blog_article` ALTER COLUMN `author_id` DROP DEFAULT;
CREATE TABLE `blog_article_tags` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `article_id` integer NOT NULL, `tag_id` integer NOT NULL, UNIQUE (`article_id`, `tag_id`));
CREATE INDEX `blog_article_4f331e2f` ON `blog_article` (`author_id`);
ALTER TABLE `blog_article` ADD CONSTRAINT `blog_article_author_id_3b0bb182_fk_blog_author_id` FOREIGN KEY (`author_id`) REFERENCES `blog_author` (`id`);
ALTER TABLE `blog_article_tags` ADD CONSTRAINT `blog_article_tags_article_id_e3a2026_fk_blog_article_id` FOREIGN KEY (`article_id`) REFERENCES `blog_article` (`id`);
ALTER TABLE `blog_article_tags` ADD CONSTRAINT `blog_article_tags_tag_id_48bab874_fk_blog_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `blog_tag` (`id`);

COMMIT;

posted @ 2017-08-07 17:50  扫驴  阅读(279)  评论(0编辑  收藏  举报