`jsonb` comparison wasn't working as expected, and duplicated entries were inserted within `flow_node`. To resolve this add a second hash column, `hash_v2` with a unique default for uniqueness, and use this new column to ensure unique entries. The previous hash column is left for backward compatibility. Duplicated entries already insterted will remain as is without breaking, and only new ones will preserve uniqueness.
5 lines
250 B
SQL
5 lines
250 B
SQL
-- Add up migration script here
|
|
CREATE SEQUENCE IF NOT EXISTS flow_node_hash_seq;
|
|
ALTER TABLE flow_node ALTER COLUMN hash DROP NOT NULL;
|
|
ALTER TABLE flow_node ADD COLUMN hash_v2 CHAR(64) NOT NULL UNIQUE DEFAULT to_hex(nextval('flow_node_hash_seq'));
|