Skip to content

Commit 0c57436

Browse files
vr009cschleiden
authored andcommitted
migrations: squash migrations into a single file
1 parent 73e15af commit 0c57436

File tree

6 files changed

+17
-65
lines changed

6 files changed

+17
-65
lines changed

backend/postgres/db/migrations/000001_initial.down.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
DROP TABLE IF EXISTS attributes;
12
DROP TABLE IF EXISTS instances;
23
DROP TABLE IF EXISTS pending_events;
34
DROP TABLE IF EXISTS history;

backend/postgres/db/migrations/000001_initial.up.sql

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CREATE TABLE instances (
99
parent_schedule_event_id numeric NULL,
1010
metadata bytea NULL,
1111
state int NOT NULL,
12+
queue varchar(128) DEFAULT '' NOT NULL,
1213
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
1314
completed_at timestamptz NULL,
1415
locked_until timestamptz NULL,
@@ -17,7 +18,7 @@ CREATE TABLE instances (
1718
);
1819

1920
CREATE UNIQUE INDEX idx_instances_instance_id_execution_id on instances (instance_id, execution_id);
20-
CREATE INDEX idx_instances_locked_until_completed_at on instances (completed_at, locked_until, sticky_until, worker);
21+
CREATE INDEX idx_instances_locked_until_completed_at_queue ON instances (completed_at, locked_until, sticky_until, worker, queue);
2122
CREATE INDEX idx_instances_parent_instance_id_parent_execution_id ON instances (parent_instance_id, parent_execution_id);
2223

2324
DROP TABLE IF EXISTS pending_events;
@@ -30,7 +31,6 @@ CREATE TABLE pending_events (
3031
event_type int NOT NULL,
3132
timestamp timestamptz NOT NULL,
3233
schedule_event_id bigserial NOT NULL,
33-
attributes bytea NOT NULL,
3434
visible_at timestamptz NULL
3535
);
3636

@@ -47,7 +47,6 @@ CREATE TABLE IF NOT EXISTS history (
4747
event_type int NOT NULL,
4848
timestamp timestamptz NOT NULL,
4949
schedule_event_id bigserial NOT NULL,
50-
attributes bytea NOT NULL,
5150
visible_at timestamptz NULL
5251
);
5352

@@ -61,13 +60,25 @@ CREATE TABLE IF NOT EXISTS activities (
6160
instance_id varchar(128) NOT NULL,
6261
execution_id varchar(128) NOT NULL,
6362
event_type int NOT NULL,
63+
queue varchar(128) DEFAULT '' NOT NULL,
6464
timestamp timestamptz NOT NULL,
6565
schedule_event_id bigserial NOT NULL,
66-
attributes bytea NOT NULL,
6766
visible_at timestamptz NULL,
6867
locked_until timestamptz NULL,
6968
worker VARCHAR(64) NULL
7069
);
7170

7271
CREATE UNIQUE INDEX idx_activities_instance_id_execution_id_activity_id_worker ON activities (instance_id, execution_id, activity_id, worker);
73-
CREATE INDEX idx_activities_locked_until on activities (locked_until);
72+
CREATE INDEX idx_activities_locked_until_queue ON activities (locked_until, queue);
73+
74+
DROP TABLE IF EXISTS attributes;
75+
CREATE TABLE attributes (
76+
id BIGSERIAL NOT NULL PRIMARY KEY,
77+
event_id varchar(128) NOT NULL,
78+
instance_id varchar(128) NOT NULL,
79+
execution_id varchar(128) NOT NULL,
80+
data bytea NOT NULL
81+
);
82+
83+
CREATE UNIQUE INDEX idx_attributes_instance_id_execution_id_event_id on attributes (instance_id, execution_id, event_id);
84+
CREATE INDEX idx_attributes_event_id on attributes (event_id);

backend/postgres/db/migrations/000002_add_attributes_table.down.sql

Lines changed: 0 additions & 11 deletions
This file was deleted.

backend/postgres/db/migrations/000002_add_attributes_table.up.sql

Lines changed: 0 additions & 24 deletions
This file was deleted.

backend/postgres/db/migrations/000003_add_queue.down.sql

Lines changed: 0 additions & 14 deletions
This file was deleted.

backend/postgres/db/migrations/000003_add_queue.up.sql

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)