Skip to content

Commit 55bf47a

Browse files
committed
Move 'id' sequence generation to 'transactions' table
The transactions table is now leading, so it makes sense to stop generating IDs for INSERT statements in AR/AP/GL.
1 parent a4ed693 commit 55bf47a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sql/changes/1.14/non-gl-transactions.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ values ('ap', 'The transaction is a regular Accounts Payable item'),
44
('ar', 'The transaction is a regular Accounts Receivable item');
55

66
alter table transactions
7+
alter column id set default nextval('id'),
78
add column description text,
89
add column trans_type_code char(2) references trans_type(code),
910
add column entered_by int references entity(id),
@@ -47,20 +48,23 @@ update transactions txn
4748
where txn.id = old.id;
4849

4950
alter table ar
51+
alter column id drop default,
5052
drop column approved,
5153
drop column description,
5254
drop constraint ar_id_fkey,
5355
-- the on delete cascade prevents deletion of approved lots (= transactions)
5456
add constraint ar_id_fkey foreign key (id) references transactions (id) on delete cascade;
5557

5658
alter table ap
59+
alter column id drop default,
5760
drop column approved,
5861
drop column description,
5962
drop constraint ap_id_fkey,
6063
-- the on delete cascade prevents deletion of approved lots (= transactions)
6164
add constraint ap_id_fkey foreign key (id) references transactions (id) on delete cascade;
6265

6366
alter table gl
67+
alter column id drop default,
6468
drop column approved,
6569
drop column description,
6670
drop column trans_type_code,

0 commit comments

Comments
 (0)