Skip to content

Commit 5da627a

Browse files
authored
Updated migrations example in tutorial 2.
Follow up to a97845a.
1 parent d82d2d4 commit 5da627a

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

docs/intro/tutorial02.txt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,9 @@ You should see something similar to the following:
240240
.. code-block:: text
241241

242242
Migrations for 'polls':
243-
polls/migrations/0001_initial.py:
244-
- Create model Choice
243+
polls/migrations/0001_initial.py
245244
- Create model Question
246-
- Add field question to choice
245+
- Create model Choice
247246

248247
By running ``makemigrations``, you're telling Django that you've made
249248
some changes to your models (in this case, you've made new ones) and that
@@ -272,14 +271,6 @@ readability):
272271

273272
BEGIN;
274273
--
275-
-- Create model Choice
276-
--
277-
CREATE TABLE "polls_choice" (
278-
"id" serial NOT NULL PRIMARY KEY,
279-
"choice_text" varchar(200) NOT NULL,
280-
"votes" integer NOT NULL
281-
);
282-
--
283274
-- Create model Question
284275
--
285276
CREATE TABLE "polls_question" (
@@ -288,16 +279,20 @@ readability):
288279
"pub_date" timestamp with time zone NOT NULL
289280
);
290281
--
291-
-- Add field question to choice
282+
-- Create model Choice
292283
--
293-
ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT NULL;
294-
ALTER TABLE "polls_choice" ALTER COLUMN "question_id" DROP DEFAULT;
295-
CREATE INDEX "polls_choice_7aa0f6ee" ON "polls_choice" ("question_id");
284+
CREATE TABLE "polls_choice" (
285+
"id" serial NOT NULL PRIMARY KEY,
286+
"choice_text" varchar(200) NOT NULL,
287+
"votes" integer NOT NULL,
288+
"question_id" integer NOT NULL
289+
);
296290
ALTER TABLE "polls_choice"
297-
ADD CONSTRAINT "polls_choice_question_id_246c99a640fbbd72_fk_polls_question_id"
291+
ADD CONSTRAINT "polls_choice_question_id_c5b4b260_fk_polls_question_id"
298292
FOREIGN KEY ("question_id")
299293
REFERENCES "polls_question" ("id")
300294
DEFERRABLE INITIALLY DEFERRED;
295+
CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" ("question_id");
301296

302297
COMMIT;
303298

0 commit comments

Comments
 (0)