我有两个简单的迁移:
0001_initial.py个
# Generated by Django 4.2.7 on 2023-11-30 11:15
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.RunSQL(
"""
CREATE TABLE comments (
id SERIAL PRIMARY KEY,
contents VARCHAR(240) NOT NULL
);
"""
),
]
0002.py个
# Generated by Django 4.2.7 on 2023-11-30 11:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("polls", "0001_initial")
]
operations = [
migrations.RunSQL(
"""
ALTER TABLE comments RENAME COLUMN contents to text;
"""
),
]
我 run :
python manage.py migrate个
然后我想undo撤消0002迁移
我在 run
python manage.py migrate polls 0001个
但是Django不知道如何撤销第二次迁移的更改.
How can I tell Django that for undoing the changes from the 0002 migration I need to run this SQL:个
ALTER TABLE comments RENAME COLUMN text to contents;
我试着寻找,但没有成功.