add envelop
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
af0d98683c
commit
1f3ed998df
8 changed files with 363 additions and 19 deletions
18
migrations/000004_envelopes_and_transactions.down.sql
Normal file
18
migrations/000004_envelopes_and_transactions.down.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
ALTER TABLE transaction DROP CONSTRAINT chk_transaction_sides;
|
||||
|
||||
ALTER TABLE transaction
|
||||
DROP COLUMN envelope_source_id,
|
||||
DROP COLUMN envelope_dest_id,
|
||||
ADD COLUMN envelope_id INTEGER REFERENCES envelope(id);
|
||||
|
||||
ALTER TABLE transaction ADD CONSTRAINT chk_transaction_sides CHECK (
|
||||
(account_source_id IS NOT NULL AND instrument_source_id IS NOT NULL AND quantite_source IS NOT NULL
|
||||
OR account_source_id IS NULL AND instrument_source_id IS NULL AND quantite_source IS NULL)
|
||||
AND
|
||||
(account_dest_id IS NOT NULL AND instrument_dest_id IS NOT NULL AND quantite_dest IS NOT NULL
|
||||
OR account_dest_id IS NULL AND instrument_dest_id IS NULL AND quantite_dest IS NULL)
|
||||
AND
|
||||
(account_source_id IS NOT NULL OR account_dest_id IS NOT NULL)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS envelope_snapshot;
|
||||
Loading…
Add table
Add a link
Reference in a new issue