@@ -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
1920CREATE 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 );
2122CREATE INDEX idx_instances_parent_instance_id_parent_execution_id ON instances (parent_instance_id, parent_execution_id);
2223
2324DROP 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
7271CREATE 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);
0 commit comments