$ python manage.py sqlmigrate users 0001
BEGIN;
--
-- Create model User
--
CREATE TABLE "users_user" ("id" serial NOT NULL PRIMARY KEY, "password" varchar(128) NOT NULL, "last_login" timestamp with time zone NOT NULL, "is_superuser" boolean NOT NULL, "username" varchar(30) NOT NULL UNIQUE, "first_name" varchar(30) NOT NULL, "last_name" varchar(30) NOT NULL, "email" varchar(75) NOT NULL, "is_staff" boolean NOT NULL, "is_active" boolean NOT NULL, "date_joined" timestamp with time zone NOT NULL, "subscriber_code" varchar(255) NOT NULL);
CREATE INDEX "users_user_username_06e46fe6_like" ON "users_user" ("username" varchar_pattern_ops);
COMMIT;
2条答案
按热度按时间3lxsmp7m1#
找出哪个应用程序和迁移最初创建了表。例如,如果创建表的模型位于名为
users
在初始迁移#0001中,可以运行以下命令转储创建表的sql:之后,您可以在sqlite中打开一个数据库shell,并通过复制和粘贴来运行sql:
祝你恢复好运!
7lrncoxx2#
删除迁移文件并重新运行
python manage.py makemigrations