2023-11-23 01:08:33 -05:00
|
|
|
# Generated by Django 4.2.7 on 2023-11-23 03:23
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
2023-11-26 17:23:53 -05:00
|
|
|
_sql = """DELETE
|
|
|
|
FROM journal_shelflogentry a USING journal_shelflogentry b
|
|
|
|
WHERE a.ctid < b.ctid
|
|
|
|
AND a.item_id=b.item_id
|
|
|
|
AND a.owner_id=b.owner_id
|
|
|
|
AND a.timestamp=b.timestamp
|
|
|
|
AND a.shelf_type=b.shelf_type"""
|
|
|
|
|
2023-11-23 01:08:33 -05:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
|
|
("journal", "0019_alter_collection_edited_time_and_more"),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2023-11-26 17:23:53 -05:00
|
|
|
migrations.RunSQL("SET CONSTRAINTS ALL IMMEDIATE;"),
|
|
|
|
migrations.RunSQL(
|
|
|
|
sql=_sql,
|
|
|
|
reverse_sql=migrations.RunSQL.noop,
|
|
|
|
),
|
|
|
|
migrations.RunSQL("SET CONSTRAINTS ALL DEFERRED;"),
|
2023-11-23 01:08:33 -05:00
|
|
|
migrations.AddConstraint(
|
|
|
|
model_name="shelflogentry",
|
|
|
|
constraint=models.UniqueConstraint(
|
|
|
|
fields=("owner", "item", "timestamp", "shelf_type"),
|
|
|
|
name="unique_shelf_log_entry",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|