Skip to content

Commit 2bb5a64

Browse files
PB-2354 Update pgtrigger for ETag update
Created with `python app/manage.py makemigrations`.
1 parent 27616b5 commit 2bb5a64

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Generated by Django 5.2.13 on 2026-06-25 09:41
2+
3+
import pgtrigger.compiler
4+
import pgtrigger.migrations
5+
6+
from django.db import migrations
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('stac_api', '0077_item_cf_standard_name_item_unit'),
13+
]
14+
15+
operations = [
16+
pgtrigger.migrations.RemoveTrigger(
17+
model_name='item',
18+
name='update_collection_child_trigger_etag_only',
19+
),
20+
pgtrigger.migrations.AddTrigger(
21+
model_name='item',
22+
trigger=pgtrigger.compiler.Trigger(
23+
name='update_collection_child_trigger_etag_only',
24+
sql=pgtrigger.compiler.UpsertTriggerSql(
25+
condition=
26+
'WHEN (OLD."cf_standard_name" IS DISTINCT FROM (NEW."cf_standard_name") OR OLD."collection_id" IS DISTINCT FROM (NEW."collection_id") OR OLD."created" IS DISTINCT FROM (NEW."created") OR OLD."etag" IS DISTINCT FROM (NEW."etag") OR OLD."forecast_duration" IS DISTINCT FROM (NEW."forecast_duration") OR OLD."forecast_horizon" IS DISTINCT FROM (NEW."forecast_horizon") OR OLD."forecast_perturbed" IS DISTINCT FROM (NEW."forecast_perturbed") OR OLD."forecast_reference_datetime" IS DISTINCT FROM (NEW."forecast_reference_datetime") OR OLD."forecast_variable" IS DISTINCT FROM (NEW."forecast_variable") OR OLD."geometry" IS DISTINCT FROM (NEW."geometry") OR OLD."id" IS DISTINCT FROM (NEW."id") OR OLD."name" IS DISTINCT FROM (NEW."name") OR OLD."properties_datetime" IS DISTINCT FROM (NEW."properties_datetime") OR OLD."properties_end_datetime" IS DISTINCT FROM (NEW."properties_end_datetime") OR OLD."properties_expires" IS DISTINCT FROM (NEW."properties_expires") OR OLD."properties_start_datetime" IS DISTINCT FROM (NEW."properties_start_datetime") OR OLD."properties_title" IS DISTINCT FROM (NEW."properties_title") OR OLD."total_data_size" IS DISTINCT FROM (NEW."total_data_size") OR OLD."unit" IS DISTINCT FROM (NEW."unit"))',
27+
declare='DECLARE child stac_api_Item%ROWTYPE;',
28+
func=
29+
"\n-- update related collection\nchild = COALESCE(NEW, OLD);\nUPDATE stac_api_collection SET\n etag = public.gen_random_uuid()\nWHERE id = child.collection_id;\n\nRAISE INFO 'Parent table collection.id=% auto fields updated due to child Item.id=% updates.',\n child.collection_id, child.id;\n\nRETURN child;\n",
30+
hash='fd8f0851644f4a1b6a44ea3def7af991b64e7f12',
31+
operation='UPDATE',
32+
pgid='pgtrigger_update_collection_child_trigger_etag_only_bee6a',
33+
table='stac_api_item',
34+
when='AFTER'
35+
)
36+
),
37+
),
38+
]

0 commit comments

Comments
 (0)