Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
-- Deploy numerus:company to pg
|
|
|
|
-- requires: schema_numerus
|
|
|
|
-- requires: extension_vat
|
|
|
|
-- requires: email
|
|
|
|
-- requires: extension_pg_libphonenumber
|
|
|
|
-- requires: extension_uri
|
|
|
|
-- requires: currency_code
|
|
|
|
-- requires: currency
|
|
|
|
|
|
|
|
begin;
|
|
|
|
|
|
|
|
set search_path to numerus,public;
|
|
|
|
|
|
|
|
create table company (
|
|
|
|
company_id serial primary key,
|
|
|
|
slug uuid not null unique default gen_random_uuid(),
|
2023-02-17 11:39:32 +00:00
|
|
|
business_name text not null constraint business_name_not_empty check (length(trim(business_name)) > 1),
|
Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
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,
|
2023-01-27 20:30:14 +00:00
|
|
|
country_code country_code not null references country,
|
Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
currency_code currency_code not null references currency,
|
2023-02-17 13:48:24 +00:00
|
|
|
invoice_number_format text not null default '"FRA"YYYY0000',
|
2023-06-07 12:14:48 +00:00
|
|
|
quote_number_format text not null default '"PRE"YYYY0000',
|
2023-03-02 09:24:44 +00:00
|
|
|
legal_disclaimer text not null default '',
|
Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
created_at timestamptz not null default current_timestamp
|
|
|
|
);
|
|
|
|
|
2023-01-27 00:08:03 +00:00
|
|
|
grant select, update on table company to invoicer;
|
|
|
|
grant select, update on table company to admin;
|
Add the company relation and read-only form to edit
I do not have more time to update the update to the company today, but i
believe this is already a good amount of work for a commit.
The company is going to be used for row level security, as users will
only have access to the data from companies they are granted access, by
virtue of being in the company_user relation.
I did not know how add a row level security policy to the company_user
because i needed the to select on the same relation and this is not
allowed, because it would create an infinite loop.
Had to add the vat, pg_libphonenumber, and uri extensions in order to
validate VAT identification numbers, phone numbers, and URIs,
repectively. These libraries are not in Debian, but i created packages
for them all in https://dev.tandem.ws/tandem.
2023-01-24 20:46:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
commit;
|