Add foreign key constraint to invoice_number_counter.company_id
This commit is contained in:
parent
35b12f7ea4
commit
775cdef097
|
@ -7,7 +7,7 @@ begin;
|
||||||
set search_path to numerus, public;
|
set search_path to numerus, public;
|
||||||
|
|
||||||
create table invoice_number_counter (
|
create table invoice_number_counter (
|
||||||
company_id integer not null,
|
company_id integer not null references company,
|
||||||
year integer not null constraint year_always_positive check(year > 0),
|
year integer not null constraint year_always_positive check(year > 0),
|
||||||
currval integer not null constraint counter_zero_or_positive check(currval >= 0),
|
currval integer not null constraint counter_zero_or_positive check(currval >= 0),
|
||||||
primary key (company_id, year)
|
primary key (company_id, year)
|
||||||
|
|
|
@ -5,7 +5,7 @@ reset client_min_messages;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
|
|
||||||
select plan(25);
|
select plan(27);
|
||||||
|
|
||||||
set search_path to numerus, auth, public;
|
set search_path to numerus, auth, public;
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ select table_privs_are('invoice_number_counter', 'admin', array ['SELECT', 'INSE
|
||||||
select table_privs_are('invoice_number_counter', 'authenticator', array []::text[]);
|
select table_privs_are('invoice_number_counter', 'authenticator', array []::text[]);
|
||||||
|
|
||||||
select has_column('invoice_number_counter', 'company_id');
|
select has_column('invoice_number_counter', 'company_id');
|
||||||
|
select col_is_fk('invoice_number_counter', 'company_id');
|
||||||
|
select fk_ok('invoice_number_counter', 'company_id', 'company', 'company_id');
|
||||||
select col_type_is('invoice_number_counter', 'company_id', 'integer');
|
select col_type_is('invoice_number_counter', 'company_id', 'integer');
|
||||||
select col_not_null('invoice_number_counter', 'company_id');
|
select col_not_null('invoice_number_counter', 'company_id');
|
||||||
select col_hasnt_default('invoice_number_counter', 'company_id');
|
select col_hasnt_default('invoice_number_counter', 'company_id');
|
||||||
|
@ -66,11 +68,6 @@ values (2, 1)
|
||||||
, (4, 5)
|
, (4, 5)
|
||||||
;
|
;
|
||||||
|
|
||||||
insert into contact (contact_id, company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code)
|
|
||||||
values (6, 2, 'Contact 1', 'XX555', '', '777-777-777', 'c@c', '', '', '', '', '', 'ES')
|
|
||||||
, (8, 4, 'Contact 2', 'XX666', '', '888-888-888', 'd@d', '', '', '', '', '', 'ES')
|
|
||||||
;
|
|
||||||
|
|
||||||
insert into invoice_number_counter (company_id, year, currval)
|
insert into invoice_number_counter (company_id, year, currval)
|
||||||
values (2, 2010, 6)
|
values (2, 2010, 6)
|
||||||
, (2, 2011, 8)
|
, (2, 2011, 8)
|
||||||
|
|
Loading…
Reference in New Issue