Skip to content

Commit e14bbe0

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

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generated by Django 5.2.13 on 2026-06-25 09:41
2+
3+
import pgtrigger.compiler
4+
import pgtrigger.migrations
5+
<<<<<<< HEAD
6+
=======
7+
8+
>>>>>>> e23ade0 (PB-2354 Update pgtrigger for ETag update)
9+
from django.db import migrations
10+
11+
12+
class Migration(migrations.Migration):
13+
14+
dependencies = [
15+
('stac_api', '0077_item_cf_standard_name_item_unit'),
16+
]
17+
18+
operations = [
19+
pgtrigger.migrations.RemoveTrigger(
20+
model_name='item',
21+
name='update_collection_child_trigger_etag_only',
22+
),
23+
pgtrigger.migrations.AddTrigger(
24+
model_name='item',
25+
<<<<<<< HEAD
26+
trigger=pgtrigger.compiler.Trigger(name='update_collection_child_trigger_etag_only', sql=pgtrigger.compiler.UpsertTriggerSql(condition='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"))', declare='DECLARE child stac_api_Item%ROWTYPE;', func="\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", hash='fd8f0851644f4a1b6a44ea3def7af991b64e7f12', operation='UPDATE', pgid='pgtrigger_update_collection_child_trigger_etag_only_bee6a', table='stac_api_item', when='AFTER')),
27+
=======
28+
trigger=pgtrigger.compiler.Trigger(
29+
name='update_collection_child_trigger_etag_only',
30+
sql=pgtrigger.compiler.UpsertTriggerSql(
31+
condition=
32+
'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"))',
33+
declare='DECLARE child stac_api_Item%ROWTYPE;',
34+
func=
35+
"\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",
36+
hash='fd8f0851644f4a1b6a44ea3def7af991b64e7f12',
37+
operation='UPDATE',
38+
pgid='pgtrigger_update_collection_child_trigger_etag_only_bee6a',
39+
table='stac_api_item',
40+
when='AFTER'
41+
)
42+
),
43+
>>>>>>> e23ade0 (PB-2354 Update pgtrigger for ETag update)
44+
),
45+
]

0 commit comments

Comments
 (0)