add re constraint from yeclose

This commit is contained in:
Paul Trowbridge 2018-10-05 14:31:36 -04:00
parent 9fa7dd7e04
commit bc331be07c
2 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,9 @@ COMMENT ON TABLE evt.acct IS 'account master list';
COMMENT ON COLUMN evt.acct.acct IS 'account'; COMMENT ON COLUMN evt.acct.acct IS 'account';
COMMENT ON COLUMN evt.acct.prop IS 'properties'; COMMENT ON COLUMN evt.acct.prop IS 'properties';
--this should effectively only allow one instance of an account where retained_earnings = set per top level account (trial balance)
CREATE UNIQUE INDEX acct_re ON evt.acct (subpath(acct,0,1)) WHERE prop ->> 'retained_earnings' = 'set';
------------------------fiscal periods------------------------ ------------------------fiscal periods------------------------
CREATE TABLE evt.fspr ( CREATE TABLE evt.fspr (
id ltree PRIMARY KEY id ltree PRIMARY KEY

View File

@ -8,3 +8,6 @@ CREATE TABLE evt.acct (
COMMENT ON TABLE evt.acct IS 'account master list'; COMMENT ON TABLE evt.acct IS 'account master list';
COMMENT ON COLUMN evt.acct.acct IS 'account'; COMMENT ON COLUMN evt.acct.acct IS 'account';
COMMENT ON COLUMN evt.acct.prop IS 'properties'; COMMENT ON COLUMN evt.acct.prop IS 'properties';
--this should effectively only allow one instance of an account where retained_earnings = set per top level account (trial balance)
CREATE UNIQUE INDEX acct_re ON evt.acct (subpath(acct,0,1)) WHERE prop ->> 'retained_earnings' = 'set';