changes
This commit is contained in:
parent
5583449c0d
commit
92005bd902
@ -4,14 +4,10 @@ create sequence account_s
|
||||
|
||||
create table account_t (
|
||||
id integer not null default nextval('account_s'),
|
||||
comment varchar(128) not null,
|
||||
description varchar(128) not null,
|
||||
constraint account_t_pk primary key (id)
|
||||
);
|
||||
|
||||
alter table account_t rename column comment to description;
|
||||
|
||||
|
||||
|
||||
create sequence tenant_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
@ -35,18 +31,6 @@ create table tenant_t (
|
||||
constraint tenant_t_account_fk foreign key (account) references account_t (id)
|
||||
);
|
||||
|
||||
alter table tenant_t rename column account to fee_account;
|
||||
|
||||
alter table tenant_t add column overhead_account integer;
|
||||
alter table tenant_t add constraint tenant_t_overhead_account_fk foreign key (overhead_account) references account_t (id);
|
||||
|
||||
alter table tenant_t add column disposit_account integer;
|
||||
alter table tenant_t add constraint tenant_t_disposit_account_fk foreign key (disposit_account) references account_t (id);
|
||||
|
||||
alter table tenant_t alter column overhead_account set not null;
|
||||
alter table tenant_t alter column disposit_account set not null;
|
||||
|
||||
|
||||
create sequence premise_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
@ -86,7 +70,6 @@ create table overhead_advance_t (
|
||||
constraint overhead_advance_t_pk primary key (id)
|
||||
);
|
||||
|
||||
|
||||
create sequence overhead_advance_flat_mapping_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
@ -100,8 +83,6 @@ create table overhead_advance_flat_mapping_t (
|
||||
constraint overhead_advance_flat_mapping_t_flat_fk foreign key (flat) references flat_t (id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
create sequence parking_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
@ -132,6 +113,7 @@ create sequence tenancy_s
|
||||
|
||||
create table tenancy_t (
|
||||
id integer not null default nextval('tenancy_s'),
|
||||
description varchar(128) default null,
|
||||
tenant integer not null,
|
||||
flat integer default null,
|
||||
parking integer default null,
|
||||
@ -150,25 +132,22 @@ create table tenancy_t (
|
||||
)
|
||||
);
|
||||
|
||||
create type fee_type_e as ENUM ('per_area', 'total');
|
||||
|
||||
create sequence fee_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
|
||||
create table fee_t (
|
||||
id integer not null default nextval('fee_s'),
|
||||
comment varchar(128) default null,
|
||||
description varchar(128) default null,
|
||||
amount numeric(10, 2) not null,
|
||||
fee_type fee_type_e not null,
|
||||
startdate date default null,
|
||||
enddate date default null,
|
||||
constraint fee_t_pk primary key (id)
|
||||
);
|
||||
|
||||
CREATE TYPE fee_type_e AS ENUM ('per_area', 'total');
|
||||
|
||||
alter table fee_t add column fee_type fee_type_e;
|
||||
ALTER TABLE fee_t ALTER COLUMN fee_type SET NOT NULL;
|
||||
|
||||
|
||||
create sequence tenancy_fee_mapping_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
@ -182,8 +161,6 @@ create table tenancy_fee_mapping_t (
|
||||
constraint tenancy_fee_mapping_t_fee_fk foreign key (fee) references fee_t (id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
create sequence account_entry_s
|
||||
start with 1
|
||||
increment by 1;
|
||||
@ -193,17 +170,7 @@ create table account_entry_t (
|
||||
account integer not null,
|
||||
created_at date not null default now(),
|
||||
amount numeric(10, 2) not null,
|
||||
comment varchar(32) not null,
|
||||
description varchar(32) not null,
|
||||
constraint account_entry_t_pk primary key (id),
|
||||
constraint account_entry_t_account_fk foreign key (account) references account_t (id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
-- create table claim_t (
|
||||
-- id integer primary key not null default nextval('claim_s'),
|
||||
-- key varchar(64) not null,
|
||||
-- value varchar(64) not null,
|
||||
-- application integer not null references application(id),
|
||||
-- unique (key, value)
|
||||
-- );
|
@ -1,12 +1,8 @@
|
||||
insert into account_t (description) values ('fee testtenant1');
|
||||
insert into account_t (description) values ('overhead testtenant1');
|
||||
insert into account_t (description) values ('disposit testtenant1');
|
||||
insert into account_t (description) values ('account testtenant1');
|
||||
|
||||
insert into tenant_t (lastname, fee_account, overhead_account, disposit_account) values (
|
||||
insert into tenant_t (lastname, account) values (
|
||||
'testtenant1',
|
||||
(select id from account_t where comment = 'fee testtenant1'),
|
||||
(select id from account_t where comment = 'overhead testtenant1'),
|
||||
(select id from account_t where comment = 'disposit testtenant1'),
|
||||
(select id from account_t where description = 'account testtenant1')
|
||||
);
|
||||
|
||||
insert into premise_t (street, zip, city) values ('Hemsingskotten 38', '45259', 'Essen');
|
||||
@ -15,19 +11,21 @@ insert into parking_t (description, premise) values ('Garage 1', (select id from
|
||||
|
||||
insert into flat_t (description, premise, area, flat_no) values('EG links', (select id from premise_t where street = 'Hemsingskotten 38'), 59.0, 1);
|
||||
|
||||
insert into fee_t (comment, amount, fee_type, startdate) values ('Altenwohnung Hemsingskotten', 5.23, 'per_area', '2021-01-01');
|
||||
insert into fee_t (description, amount, fee_type, startdate) values ('Altenwohnung Hemsingskotten', 5.23, 'per_area', '2021-01-01');
|
||||
|
||||
insert into fee_t (comment, amount, fee_type, startdate) values ('Garage intern', 30.0, 'total', '2021-01-01');
|
||||
insert into fee_t (description, amount, fee_type, startdate) values ('Garage intern', 30.0, 'total', '2021-01-01');
|
||||
|
||||
insert into tenancy_t (tenant, flat, startdate) values (
|
||||
insert into tenancy_t (tenant, flat, description, startdate) values (
|
||||
(select id from tenant_t where lastname = 'testtenant1'),
|
||||
(select id from flat_t where flat_no = 1),
|
||||
'flat testtenant1',
|
||||
'2021-06-01'
|
||||
);
|
||||
|
||||
insert into tenancy_t (tenant, parking, startdate) values (
|
||||
insert into tenancy_t (tenant, parking, description, startdate) values (
|
||||
(select id from tenant_t where lastname = 'testtenant1'),
|
||||
(select id from parking_t where description = 'Garage 1'),
|
||||
'parking testtenant1',
|
||||
'2021-06-01'
|
||||
);
|
||||
|
||||
@ -38,3 +36,13 @@ insert into overhead_advance_flat_mapping_t (overhead_advance, flat) values (
|
||||
(select id from flat_t where flat_no = 1)
|
||||
);
|
||||
|
||||
insert into tenancy_fee_mapping_t (tenancy, fee) values (
|
||||
(select id from tenancy_t where description = 'flat testtenant1'),
|
||||
(select id from fee_t where description = 'Altenwohnung Hemsingskotten')
|
||||
);
|
||||
|
||||
insert into tenancy_fee_mapping_t (tenancy, fee) values (
|
||||
(select id from tenancy_t where description = 'parking testtenant1'),
|
||||
(select id from fee_t where description = 'Garage intern')
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user