Delete all invoices and tied components

When a customer wants to delete all invoices and credited invoices from Atomia, remove links from subscriptions towards invoices and reset invoice counters.

The queries were written in Postgres query language. The used database is AtomiaBilling

Delete all invoices

delete from created_invoice_line_tax; delete from credited_invoice_line_custom_attribute; delete from credited_invoice_line; delete from credited_invoice_custom_attribute; delete from credited_invoice;


Remove links from subscriptions towards invoices 

update subscription set fk_invoice_id = null;


Delete all credited invoices

delete from invoice_line_tax; delete from invoice_line_custom_attribute; delete from invoice_line; delete from invoice_custom_attribute ; delete from invoice;

Reset invoice counters

update sequence_counter set value = 10000 where counter_type in (0,1);