I can not use a PostgreSQL sequence because invoices need to be gapless, and sequences are designed to not rollback, for performance reasons. In this case, the performance is secondary because the law does not care.
15 lines
398 B
PL/PgSQL
15 lines
398 B
PL/PgSQL
-- Verify numerus:invoice_number_counter on pg
|
|
|
|
begin;
|
|
|
|
select company_id
|
|
, year
|
|
, currval
|
|
from numerus.invoice_number_counter
|
|
where false;
|
|
|
|
select 1 / count(*) from pg_class where oid = 'numerus.invoice_number_counter'::regclass and relrowsecurity;
|
|
select 1 / count(*) from pg_policy where polname = 'company_policy' and polrelid = 'numerus.invoice_number_counter'::regclass;
|
|
|
|
rollback;
|