kopia lustrzana https://github.com/wagtail/wagtail
Use new migration rather than modifying existing in place
This won't change the impact, but ensures deployments definitely have a reset counter, even if they've already released 5.0.stable/5.1.x
rodzic
bb2ebf94cf
commit
aa7012963b
|
@ -1,18 +1,6 @@
|
|||
# Generated by Django 3.1.8 on 2021-06-22 14:56
|
||||
|
||||
from django.db import migrations
|
||||
from django.core.management.color import no_style
|
||||
|
||||
|
||||
def reset_search_promotion_sequence(apps, schema_editor):
|
||||
Query = apps.get_model("wagtailsearchpromotions.Query")
|
||||
QueryDailyHits = apps.get_model("wagtailsearchpromotions.QueryDailyHits")
|
||||
|
||||
statements = schema_editor.connection.ops.sequence_reset_sql(
|
||||
no_style(), [Query, QueryDailyHits]
|
||||
)
|
||||
for statement in statements:
|
||||
schema_editor.execute(statement)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -39,9 +27,4 @@ class Migration(migrations.Migration):
|
|||
""",
|
||||
"",
|
||||
),
|
||||
# We set an explicit pk instead of relying on auto-incrementation,
|
||||
# so we need to reset the database sequence.
|
||||
migrations.RunPython(
|
||||
reset_search_promotion_sequence, migrations.RunPython.noop
|
||||
),
|
||||
]
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 4.0.10 on 2023-09-07 10:41
|
||||
|
||||
from django.db import migrations
|
||||
from django.core.management.color import no_style
|
||||
|
||||
|
||||
def reset_search_promotion_sequence(apps, schema_editor):
|
||||
"""
|
||||
We set an explicit pk instead of relying on auto-incrementation in migration 0004,
|
||||
so we need to reset the database sequence.
|
||||
"""
|
||||
Query = apps.get_model("wagtailsearchpromotions.Query")
|
||||
QueryDailyHits = apps.get_model("wagtailsearchpromotions.QueryDailyHits")
|
||||
|
||||
statements = schema_editor.connection.ops.sequence_reset_sql(
|
||||
no_style(), [Query, QueryDailyHits]
|
||||
)
|
||||
for statement in statements:
|
||||
schema_editor.execute(statement)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("wagtailsearchpromotions", "0005_switch_query_model"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
reset_search_promotion_sequence, migrations.RunPython.noop
|
||||
),
|
||||
]
|
Ładowanie…
Reference in New Issue