Catcher:mysite catcher$ python manage.py makemigrations booksmigrations for ' books ': 0001_initial.py:-Create model A Uthor-create model book-create Model publisher-add field Publisher to bookcatcher:mysite catcher$ python ma nage.py sqlmigrate books 0001BEGIN;----Create model author--create TABLE "Books_author" ("id" integer not NULL PRIMARY KE Y AutoIncrement, "first_name" varchar (+) NOT NULL, "last_name" varchar (+) NOT NULL, "email" varchar (254) is not NULL);---- Create model Book--create TABLE "Books_book" ("id" integer not NULL PRIMARY KEY autoincrement, "title" varchar (+) not NU LL, "publication_date" date not NULL); CREATE TABLE "Books_book_authors" ("id" integer NOT null PRIMARY KEY autoincrement, "book_id" Integer NOT NULL REFERENCES "Books_book" ("id"), "author_id" Integer not NULL REFERENCES "Books_author" ("id"));----Create model Publisher--create TA BLE "Books_publisher" ("id" integer NOT null PRIMARY KEY autoincrement, "name" varchar (+) NOT NULL, "addresS "varchar" is not NULL, "city" varchar () is not null, "state_province" varchar (+) is not NULL, "country" varchar (no NUL) L, "website" varchar (no NULL);----Add field publisher to Book--alter TABLE "Books_book" RENAME to "Books_book__old" ; CREATE TABLE "Books_book" ("id" integer NOT null PRIMARY KEY AutoIncrement, "title" varchar (+) NOT NULL, "Publication_da Te ' date not null, ' publisher_id ' integer NOT null REFERENCES ' Books_publisher ' ("id")), INSERT into "Books_book" ("Publica Tion_date "," publisher_id "," id "," title ") Select" Publication_date ", NULL," id "," title "from" Books_book__old ";D rop tab LE "Books_book__old"; CREATE INDEX "Books_book_2604cbea" On "Books_book" ("publisher_id"); Commit;catcher:mysite catcher$
Django Create database Table method