kopia lustrzana https://github.com/wagtail/wagtail
Reset search promotions sequence after copying table content
We insert values manually, including an explicit pk, but don't ensure the sequence is set to a value higher than the largest pk. See also https://code.djangoproject.com/ticket/17415stable/5.1.x
rodzic
587fb4d176
commit
bb2ebf94cf
wagtail/contrib/search_promotions/migrations
|
@ -1,6 +1,18 @@
|
|||
# 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):
|
||||
|
@ -27,4 +39,9 @@ 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
|
||||
),
|
||||
]
|
||||
|
|
Ładowanie…
Reference in New Issue