camper/deploy/company.sql

45 lines
1.3 KiB
PL/PgSQL

-- Deploy camper:company to pg
-- requires: roles
-- requires: schema_camper
-- requires: extension_vat
-- requires: email
-- requires: extension_pg_libphonenumber
-- requires: extension_uri
-- requires: currency_code
-- requires: currency
-- requires: country_code
-- requires: country
-- requires: language
begin;
set search_path to camper, public;
create table company (
company_id integer generated by default as identity primary key,
slug uuid not null unique default gen_random_uuid(),
business_name text not null constraint business_name_not_empty check (length(trim(business_name)) > 1),
vatin vatin not null,
trade_name text not null,
phone packed_phone_number not null,
email email not null,
web uri not null,
address text not null,
city text not null,
province text not null,
postal_code text not null,
country_code country_code not null references country,
rtc_number text not null,
currency_code currency_code not null references currency,
default_lang_tag text not null references language,
invoice_number_format text not null default '"FRA"YYYY0000',
legal_disclaimer text not null default '',
created_at timestamptz not null default current_timestamp
);
grant select on table company to guest;
grant select on table company to employee;
grant select, update on table company to admin;
commit;