-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dropping constraints and indexes before drop table or column
- Loading branch information
Showing
26 changed files
with
1,129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
142 changes: 142 additions & 0 deletions
142
tests/apps/good_flow_drop_column_with_constraints/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.db.models.functions.math | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="TestTableParent", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
], | ||
options={ | ||
"db_table": "drop_col_test_table_parent", | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="TestTableMain", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("main_id", models.IntegerField(null=True, unique=True)), | ||
("field_u1", models.IntegerField(null=True)), | ||
("field_u2", models.IntegerField(null=True)), | ||
("field_u3", models.IntegerField(null=True)), | ||
("field_u4", models.IntegerField(null=True)), | ||
("field_i1", models.IntegerField(null=True)), | ||
("field_i2", models.IntegerField(null=True)), | ||
("field_i3", models.IntegerField(null=True)), | ||
("field_i4", models.IntegerField(null=True)), | ||
( | ||
"parent", | ||
models.OneToOneField( | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="good_flow_drop_column_with_constraints.testtableparent", | ||
), | ||
), | ||
], | ||
options={ | ||
"db_table": "drop_col_test_table_main", | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="TestTableChild", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"main", | ||
models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="good_flow_drop_column_with_constraints.testtablemain", | ||
to_field="main_id", | ||
), | ||
), | ||
], | ||
options={ | ||
"db_table": "drop_col_test_table_child", | ||
}, | ||
), | ||
migrations.AddIndex( | ||
model_name="testtablemain", | ||
index=models.Index( | ||
models.F("parent"), models.F("field_i1"), name="drop_col_i1" | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="testtablemain", | ||
index=models.Index( | ||
django.db.models.functions.math.Abs("field_i2"), name="drop_col_i2" | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="testtablemain", | ||
index=models.Index( | ||
models.F("parent"), | ||
condition=models.Q(("field_i3__gt", 0)), | ||
name="drop_col_i3", | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="testtablemain", | ||
index=models.Index( | ||
models.F("parent"), include=("field_i4",), name="drop_col_i4" | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="testtablemain", | ||
constraint=models.UniqueConstraint( | ||
models.F("parent"), models.F("field_u1"), name="drop_col_u1" | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="testtablemain", | ||
constraint=models.UniqueConstraint( | ||
django.db.models.functions.math.Abs("field_u2"), name="drop_col_u2" | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="testtablemain", | ||
constraint=models.UniqueConstraint( | ||
models.F("parent"), | ||
condition=models.Q(("field_u3__gt", 0)), | ||
name="drop_col_u3", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="testtablemain", | ||
constraint=models.UniqueConstraint( | ||
models.F("parent"), include=("field_u4",), name="drop_col_u4" | ||
), | ||
), | ||
] |
52 changes: 52 additions & 0 deletions
52
...drop_column_with_constraints/migrations/0002_remove_testtablemain_drop_col_u1_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("good_flow_drop_column_with_constraints", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.SeparateDatabaseAndState( | ||
database_operations=[], | ||
state_operations=[ | ||
migrations.RemoveConstraint( | ||
model_name="testtablemain", | ||
name="drop_col_u1", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="testtablemain", | ||
name="drop_col_u2", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="testtablemain", | ||
name="drop_col_u3", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="testtablemain", | ||
name="drop_col_u4", | ||
), | ||
migrations.RemoveIndex( | ||
model_name="testtablemain", | ||
name="drop_col_i1", | ||
), | ||
migrations.RemoveIndex( | ||
model_name="testtablemain", | ||
name="drop_col_i2", | ||
), | ||
migrations.RemoveIndex( | ||
model_name="testtablemain", | ||
name="drop_col_i3", | ||
), | ||
migrations.RemoveIndex( | ||
model_name="testtablemain", | ||
name="drop_col_i4", | ||
), | ||
migrations.RemoveField( | ||
model_name="testtablechild", | ||
name="main", | ||
), | ||
], | ||
) | ||
] |
Oops, something went wrong.