Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions database/odca.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2948,3 +2948,29 @@ INSERT INTO odca.schema_migrations(version,name,checksum)
VALUES(27,'Traceable signature preparation and confirmation evidence','ad707eeb447350489a75d60a36530b0ebe7da857ce6991f7161ca462fc332afa') ON CONFLICT(version) DO NOTHING;
COMMIT;
-- ODCA-END 027

-- ODCA-MIGRATION 028 CHECKSUM 1fa0b11b1f2728c7d1d868d9a230a0113d68c9e4a9d24de140d484b6bb456453
BEGIN;
SELECT pg_advisory_xact_lock(hashtext('odca.schema.migrations'));

CREATE TABLE odca.signature_preparation_operations(
tenant_id uuid NOT NULL, preparation_id uuid NOT NULL, operation_id uuid NOT NULL,
operation_type text NOT NULL CHECK(operation_type IN('confirm','reopen')),
command_sha256 char(64) NOT NULL, response jsonb NOT NULL, actor_user_id uuid NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY(tenant_id,operation_id),
FOREIGN KEY(tenant_id,preparation_id) REFERENCES odca.signature_preparations(tenant_id,id),
FOREIGN KEY(tenant_id,actor_user_id) REFERENCES odca.memberships(tenant_id,user_id));
CREATE INDEX signature_preparation_operations_preparation_ix
ON odca.signature_preparation_operations(tenant_id,preparation_id,created_at);
ALTER TABLE odca.signature_preparation_operations ENABLE ROW LEVEL SECURITY;
ALTER TABLE odca.signature_preparation_operations FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON odca.signature_preparation_operations TO odca_app
USING(tenant_id=nullif(current_setting('odca.tenant_id',true),'')::uuid)
WITH CHECK(tenant_id=nullif(current_setting('odca.tenant_id',true),'')::uuid);
GRANT SELECT,INSERT ON odca.signature_preparation_operations TO odca_app;

INSERT INTO odca.schema_migrations(version,name,checksum)
VALUES(28,'Idempotent signature preparation operations','1fa0b11b1f2728c7d1d868d9a230a0113d68c9e4a9d24de140d484b6bb456453') ON CONFLICT(version) DO NOTHING;
COMMIT;
-- ODCA-END 028
Loading
Loading