This commit is contained in:
2025-11-02 14:36:58 +01:00
parent 928c94e9c8
commit ace5f22f93
4 changed files with 185 additions and 9 deletions

View File

@@ -469,10 +469,10 @@ END $$;
DROP table exchange;
-- ----------------------------------------------------------------------
-- Titulaires
-- Titulaires (Holders)
-- ----------------------------------------------------------------------
CREATE TABLE bank.titulaire (
CREATE TABLE bank.holder (
id bigint primary key generated always as identity,
type_titulaire TEXT CHECK (type_titulaire IN ('individu', 'société')) NOT NULL,
created_at timestamp with time zone not null default now()
@@ -484,7 +484,7 @@ DECLARE
new_titulaire_id INTEGER;
BEGIN
IF NEW.id IS NULL THEN
INSERT INTO bank.titulaire (type_titulaire) VALUES ('individu')
INSERT INTO bank.holder (type_titulaire) VALUES ('individu')
RETURNING id INTO new_titulaire_id;
NEW.id := new_titulaire_id;
END IF;
@@ -503,7 +503,7 @@ DECLARE
new_titulaire_id INTEGER;
BEGIN
IF NEW.id IS NULL THEN
INSERT INTO bank.titulaire (type_titulaire) VALUES ('société')
INSERT INTO bank.holder (type_titulaire) VALUES ('société')
RETURNING id INTO new_titulaire_id;
NEW.id := new_titulaire_id;
END IF;
@@ -530,7 +530,7 @@ create table bank.account (
create table bank.account_holders (
account_id bigint NOT NULL REFERENCES bank.account(id) ON DELETE CASCADE,
titulaire_id int NOT NULL REFERENCES bank.titulaire(id) ON DELETE CASCADE,
titulaire_id int NOT NULL REFERENCES bank.holder(id) ON DELETE CASCADE,
share numeric(5,2) CHECK (share >= 0 AND share <= 100),
role text DEFAULT 'Titulaire',
PRIMARY KEY (account_id, titulaire_id)