added support for multiple accounts

This commit is contained in:
Peter Wood
2023-03-04 21:10:46 -05:00
parent e88dffe457
commit 098ea60ef0
5 changed files with 71 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
drop table if exists public.accounts;
drop table if exists public.accounts cascade;
CREATE TABLE public.accounts(
acct_id serial,
@@ -6,14 +6,20 @@ CREATE TABLE public.accounts(
account_type varchar(50) not null,
account_number varchar(20) null,
friendly_name varchar(50) null,
insert_dt_tm timestamp default now(),
insert_dt_tm timestamp null default now(),
PRIMARY KEY( acct_id )
);
INSERT INTO public.accounts (bank_name, account_type, friendly_name) values
('Bank of America', 'Checking', 'Joint Checking')
, ('Ally', 'Savings', 'Joint Savings')
, ('Ally', 'Savings', 'Vacation Savings')
-- Permissions
select * from public.accounts a
ALTER TABLE public.accounts OWNER TO acedanger;
GRANT ALL ON TABLE public.accounts TO acedanger;
GRANT ALL ON TABLE public.accounts TO budgetuser;
-- Populate table
truncate public.accounts;
INSERT INTO public.accounts (bank_name, account_type, friendly_name, account_number) values
('Bank of America', 'Checking', 'Joint Checking', '4581')
, ('Ally', 'Savings', 'Joint Savings', '9969')
, ('Ally', 'Savings', 'Vacation Savings', '6268')

View File

@@ -1,19 +1,21 @@
-- public.budgetdetails definition
-- Drop table
DROP TABLE public.budgetdetails;
DROP table if exists public.budgetdetails cascade;
CREATE TABLE public.budgetdetails (
trxid uuid NOT NULL DEFAULT uuid_generate_v4(),
trxdescription text NOT NULL,
trxdate date NOT NULL,
trxamount money NOT NULL,
insertdttm timestamp NULL DEFAULT now(),
CONSTRAINT budgetdetails_pkey PRIMARY KEY (trxid)
trx_id uuid NOT NULL DEFAULT uuid_generate_v4(),
trx_description text NOT NULL,
trx_date date NOT NULL,
trx_amount numeric NOT NULL,
acct_id int NULL,
insert_dt_tm timestamp NULL DEFAULT now(),
primary key ( trx_id ),
constraint fk_acct foreign key ( acct_id ) references public.accounts(acct_id) on delete set null
);
-- Permissions
ALTER TABLE public.budgetdetails OWNER TO acedanger;
GRANT ALL ON TABLE public.budgetdetails TO acedanger;
GRANT ALL ON TABLE public.budgetdetails TO budgetuser;
GRANT ALL ON TABLE public.budgetdetails TO budgetuser;