From 7e08464b2a42048ebb5128bec5731719cf8bd1db Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Sun, 29 Mar 2026 15:06:30 +0200 Subject: feat: create transaction schema --- migrations/20260329120607_functions.sql | 7 +++++++ migrations/20260329120645_transaction_schema.sql | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 migrations/20260329120607_functions.sql create mode 100644 migrations/20260329120645_transaction_schema.sql (limited to 'migrations') diff --git a/migrations/20260329120607_functions.sql b/migrations/20260329120607_functions.sql new file mode 100644 index 0000000..f662c25 --- /dev/null +++ b/migrations/20260329120607_functions.sql @@ -0,0 +1,7 @@ +create or replace function update_updated_at_column() +returns trigger as $$ +begin + new.updated_at = now(); + return new; +end; +$$ language 'plpgsql'; diff --git a/migrations/20260329120645_transaction_schema.sql b/migrations/20260329120645_transaction_schema.sql new file mode 100644 index 0000000..d7b4744 --- /dev/null +++ b/migrations/20260329120645_transaction_schema.sql @@ -0,0 +1,18 @@ +-- Add migration script here +-- The transaction's blueprint to be checked on each request +create table transaction_schema ( + -- The transaction type + type text not null, + -- The schema's version (to allow for multiple revisions - maybe) + version varchar not null, + -- Actual JSON schema + json_schema jsonb not null, + created_at timestamptz not null default now(), + updated_at timestamptz not null default now(), + primary key (type, version) +); + +create trigger update_transaction_schema_modtime + before update on transaction_schema + for each row + execute function update_updated_at_column(); -- cgit v1.2.3