Loc*_*gar 3 database django sql-delete
我更改了模型并进行了迁移。然后我又更改了一次模型,当尝试 python manage.py migrate 时,我收到错误:
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, shop
Running migrations:
Applying shop.0004_auto_20180128_1331...Traceback (most recent call last):
File "/home/morilon/dj/intshop/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/morilon/dj/intshop/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 301, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: table "shop_brand" already exists
Run Code Online (Sandbox Code Playgroud)
所以我的问题是 - 如何删除表“shop_brand”???我已经尝试过flush,sqlflush但这只从表中删除数据,而不是实际表“shop_brand”。
我使用 django 2.0.1 和 python 3.6
Kev*_* L. 12
使用 dbshell 命令
python manage.py dbshell
Run Code Online (Sandbox Code Playgroud)
然后在 shell 中,根据您使用的数据库,键入命令以显示表以标识要删除的表。
例如,对于 sqlite,您将使用
.tables
仍在shell中,您可以使用SQL命令删除表
DROP TABLE shop_brand;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17970 次 |
| 最近记录: |