Skip to content

Commit

Permalink
Update test_migrations_are_safe.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Oct 28, 2024
1 parent 23c08ee commit 34d86d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions posthog/management/commands/test_migrations_are_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def validate_migration_sql(sql) -> bool:
and not re.search(r"ADD COLUMN .+ NULL CONSTRAINT", operation_sql)
and "-- existing-table-constraint-ignore" not in operation_sql
and " NOT VALID" not in operation_sql
and " VALIDATE CONSTRAINT "
not in operation_sql # VALIDATE CONSTRAINT is a different, non-locking operation
# VALIDATE CONSTRAINT is a different, non-locking operation
and " VALIDATE CONSTRAINT " not in operation_sql
and (
table_being_altered not in tables_created_so_far
or _get_table("ALTER TABLE", operation_sql) not in new_tables # Ignore for brand-new tables
Expand All @@ -85,7 +85,7 @@ def validate_migration_sql(sql) -> bool:
"If adding a foreign key field, see `0415_pluginconfig_match_action` for an example of how to do this safely. "
"If adding the constraint by itself, please use `AddConstraintNotValid()` of `django.contrib.postgres.operations` instead. "
"See https://docs.djangoproject.com/en/4.2/ref/contrib/postgres/operations/#adding-constraints-without-enforcing-validation.\n"
"Source: `{operation_sql}`"
f"Source: `{operation_sql}`"
)
return True
if (
Expand All @@ -98,7 +98,7 @@ def validate_migration_sql(sql) -> bool:
"If adding a foreign key field, see `0415_pluginconfig_match_action` for an example of how to do this safely. "
"If adding the index by itself, please use `AddIndexConcurrently()` of `django.contrib.postgres.operations` instead. "
"See https://docs.djangoproject.com/en/4.2/ref/contrib/postgres/operations/#concurrent-index-operations.\n"
"Source: `{operation_sql}`"
f"Source: `{operation_sql}`"
)
return True

Expand Down

0 comments on commit 34d86d6

Please sign in to comment.