Skip to content

Commit

Permalink
fix idempotent mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbicr committed Jun 7, 2024
1 parent ac7134c commit 8b621e1
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 110 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- added `ZERO_DOWNTIME_MIGRATIONS_DROP_CONSTRAINS_BEFORE_CASCADE` settings and added dropping constraints and indexes before drop column or table
- fixed sqlmigrate in idempotent mode
- fixed creation unique constraint with include parameter
- fixed idempotent mode tests
- updated unsafe migrations links to documentation
- updated patched code to latest django version
- updated test image to ubuntu 24.04
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ RUN apt-get install -q -y --no-install-recommends \
python3.11 python3.11-distutils \
python3.12 \
python3-pip \
libgdal34
libgdal34 \
postgresql-client
RUN pip3 install --break-system-packages setuptools tox

ADD . /app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class Migration(migrations.Migration):
migrations.AddIndex(
model_name="relatedtesttable",
index=models.Index(
condition=models.Q(("test_field_int__gt", 0)),
fields=["test_field_int", "test_field_str"],
name="relatedtesttable_idx",
fields=["test_field_int", "test_field_str"], name="relatedtesttable_idx"
),
),
]
1 change: 0 additions & 1 deletion tests/apps/idempotency_add_index_meta_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ class Meta:
models.Index(
name="relatedtesttable_idx",
fields=["test_field_int", "test_field_str"],
condition=models.Q(test_field_int__gt=0),
)
]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Migration(migrations.Migration):
migrations.AddConstraint(
model_name="relatedtesttable",
constraint=models.UniqueConstraint(
condition=models.Q(("test_field_int__gt", 0)),
fields=("test_field_int", "test_field_str"),
name="relatedtesttable_uniq",
),
Expand Down
1 change: 0 additions & 1 deletion tests/apps/idempotency_add_unique_meta_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ class Meta:
models.UniqueConstraint(
name="relatedtesttable_uniq",
fields=["test_field_int", "test_field_str"],
condition=models.Q(test_field_int__gt=0),
)
]
6 changes: 3 additions & 3 deletions tests/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def pg_dump(table: str) -> str:
host = settings.DATABASES["default"]["HOST"]
port = settings.DATABASES["default"]["PORT"]
name = settings.DATABASES["default"]["NAME"]
user = settings.DATABASES["default"]["USER"]
password = settings.DATABASES["default"]["PASSWORD"]
user = settings.DB_SUPER_USER
password = settings.DB_SUPER_PASSWORD
env = os.environ.copy() | {"PGPASSWORD": password}
cmd = f"pg_dump -h {host} -p {port} -U {user} -d {name} -s -t {table}"
popen = subprocess.run(cmd, env=env, text=True, shell=True, capture_output=True)
popen = subprocess.run(cmd, env=env, text=True, shell=True, capture_output=True, check=True)
return popen.stdout


Expand Down
263 changes: 163 additions & 100 deletions tests/integration/test_migrations.py

Large diffs are not rendered by default.

0 comments on commit 8b621e1

Please sign in to comment.