mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-20 23:17:30 +03:00
server: add unique constraints to the cron events table (#1131)
GitOrigin-RevId: 3939001a90de041d588c4133ecc1b28b35734d72
This commit is contained in:
parent
8222651c4b
commit
2d9959b174
@ -1 +1 @@
|
||||
45
|
||||
46
|
||||
|
@ -61,6 +61,10 @@ CREATE TABLE hdb_catalog.hdb_cron_events
|
||||
|
||||
CREATE INDEX hdb_cron_event_status ON hdb_catalog.hdb_cron_events (status);
|
||||
|
||||
CREATE UNIQUE INDEX hdb_cron_events_unique_scheduled ON
|
||||
hdb_catalog.hdb_cron_events (trigger_name, scheduled_time)
|
||||
where status = 'scheduled';
|
||||
|
||||
CREATE TABLE hdb_catalog.hdb_cron_event_invocation_logs
|
||||
(
|
||||
id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,
|
||||
|
7
server/src-rsr/migrations/45_to_46.sql
Normal file
7
server/src-rsr/migrations/45_to_46.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- This index is added to avoid creating duplicate cron
|
||||
-- events when multiple Hasura instances are running.
|
||||
-- This is a partial index for backwards compatibility i.e.
|
||||
-- the metadata db might already have duplicated events before this change was added.
|
||||
CREATE UNIQUE INDEX hdb_cron_events_unique_scheduled
|
||||
ON hdb_catalog.hdb_cron_events (trigger_name, scheduled_time)
|
||||
WHERE status = 'scheduled';
|
1
server/src-rsr/migrations/46_to_45.sql
Normal file
1
server/src-rsr/migrations/46_to_45.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP INDEX hdb_catalog.hdb_cron_events_unique_scheduled;
|
Loading…
Reference in New Issue
Block a user