Skip to content

Commit

Permalink
chore: remove revision from Durable State primary key (#559)
Browse files Browse the repository at this point in the history
* chore: remove revision from Durable State primary key
  • Loading branch information
sebastian-alfers authored Apr 23, 2024
1 parent bb19e4f commit d579807
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ddl-scripts/create_tables_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS durable_state (
state_payload BYTEA NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

-- `durable_state_slice_idx` is only needed if the slice based queries are used
Expand Down
4 changes: 2 additions & 2 deletions ddl-scripts/create_tables_postgres_0-1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CREATE TABLE IF NOT EXISTS durable_state_0 (
state_payload BYTEA NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

CREATE TABLE IF NOT EXISTS durable_state_1 (
Expand All @@ -117,7 +117,7 @@ CREATE TABLE IF NOT EXISTS durable_state_1 (
state_payload BYTEA NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

-- `durable_state_slice_idx` is only needed if the slice based queries are used
Expand Down
4 changes: 2 additions & 2 deletions ddl-scripts/create_tables_postgres_2-3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CREATE TABLE IF NOT EXISTS durable_state_2 (
state_payload BYTEA NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

CREATE TABLE IF NOT EXISTS durable_state_3 (
Expand All @@ -117,7 +117,7 @@ CREATE TABLE IF NOT EXISTS durable_state_3 (
state_payload BYTEA NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

-- `durable_state_slice_idx` is only needed if the slice based queries are used
Expand Down
2 changes: 1 addition & 1 deletion ddl-scripts/create_tables_postgres_jsonb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS durable_state (
state_payload JSONB NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

-- `durable_state_slice_idx` is only needed if the slice based queries are used
Expand Down
2 changes: 1 addition & 1 deletion ddl-scripts/create_tables_sqlserver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IF object_id('durable_state') is null
state_payload VARBINARY(MAX) NOT NULL,
tags NVARCHAR(255),

PRIMARY KEY(persistence_id, revision)
PRIMARY KEY(persistence_id)
);

-- `durable_state_slice_idx` is only needed if the slice based queries are used
Expand Down
2 changes: 1 addition & 1 deletion ddl-scripts/create_tables_yugabyte.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CREATE TABLE IF NOT EXISTS durable_state (
state_payload BYTEA NOT NULL,
tags TEXT ARRAY,

PRIMARY KEY(persistence_id HASH, revision ASC)
PRIMARY KEY(persistence_id HASH)
);

-- `durable_state_slice_idx` is only needed if the slice based queries are used
Expand Down
16 changes: 16 additions & 0 deletions docs/src/main/paradox/migration-guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Migration Guide

## 1.2.x to 1.3.0

### Durable State table schema change (optional)
The existing primary key for the Durable State table was containing an unnecessary column.

Please run the following query to update the table constraint:

Postgres / Yugabyte:
: ```sql
ALTER TABLE "durable_state"
DROP CONSTRAINT durable_state_pkey,
ADD PRIMARY KEY(persistence_id);
```
If you are using @ref[data partitioning](./data-partition.md), please make sure to apply the change to all tables.
## 1.1.x to 1.2.0
### Configuration file changes
Expand Down

0 comments on commit d579807

Please sign in to comment.