-- Rollback invoice hardening.

DROP INDEX IF EXISTS idx_invoices_payment_id;
DROP INDEX IF EXISTS idx_invoices_status_issued_at;
DROP SEQUENCE IF EXISTS invoice_number_seq;
DROP INDEX IF EXISTS uq_billing_profiles_default_per_user;
DROP INDEX IF EXISTS idx_billing_profiles_user;
DROP TABLE IF EXISTS billing_profiles;
DROP INDEX IF EXISTS idx_invoice_line_items_invoice;
DROP TABLE IF EXISTS invoice_line_items;

ALTER TABLE invoices DROP CONSTRAINT IF EXISTS invoices_total_matches;
ALTER TABLE invoices DROP CONSTRAINT IF EXISTS invoices_amounts_nonneg;
ALTER TABLE invoices DROP CONSTRAINT IF EXISTS invoices_invoice_type_valid;
ALTER TABLE invoices DROP CONSTRAINT IF EXISTS invoices_status_valid;

ALTER TABLE invoices DROP COLUMN IF EXISTS updated_at;
ALTER TABLE invoices DROP COLUMN IF EXISTS created_at;
ALTER TABLE invoices DROP COLUMN IF EXISTS pdf_object_key;
ALTER TABLE invoices DROP COLUMN IF EXISTS void_reason;
ALTER TABLE invoices DROP COLUMN IF EXISTS voided_by_user_id;
ALTER TABLE invoices DROP COLUMN IF EXISTS voided_at;
ALTER TABLE invoices DROP COLUMN IF EXISTS paid_at;
ALTER TABLE invoices DROP COLUMN IF EXISTS notes;
ALTER TABLE invoices DROP COLUMN IF EXISTS discount_label;
ALTER TABLE invoices DROP COLUMN IF EXISTS discount_amount;
ALTER TABLE invoices DROP COLUMN IF EXISTS customer_state_code;
ALTER TABLE invoices DROP COLUMN IF EXISTS customer_gstin;
ALTER TABLE invoices DROP COLUMN IF EXISTS customer_billing_address;
ALTER TABLE invoices DROP COLUMN IF EXISTS customer_phone;
ALTER TABLE invoices DROP COLUMN IF EXISTS customer_email;
ALTER TABLE invoices DROP COLUMN IF EXISTS customer_name;
ALTER TABLE invoices DROP COLUMN IF EXISTS seller_state_code;
ALTER TABLE invoices DROP COLUMN IF EXISTS seller_pan;
ALTER TABLE invoices DROP COLUMN IF EXISTS seller_gstin;
ALTER TABLE invoices DROP COLUMN IF EXISTS seller_address;
ALTER TABLE invoices DROP COLUMN IF EXISTS seller_name;
ALTER TABLE invoices DROP COLUMN IF EXISTS reverse_charge;
ALTER TABLE invoices DROP COLUMN IF EXISTS seller_state;
ALTER TABLE invoices DROP COLUMN IF EXISTS place_of_supply_state;
ALTER TABLE invoices DROP COLUMN IF EXISTS igst_amount;
ALTER TABLE invoices DROP COLUMN IF EXISTS igst_rate;
ALTER TABLE invoices DROP COLUMN IF EXISTS sgst_amount;
ALTER TABLE invoices DROP COLUMN IF EXISTS sgst_rate;
ALTER TABLE invoices DROP COLUMN IF EXISTS cgst_amount;
ALTER TABLE invoices DROP COLUMN IF EXISTS cgst_rate;
ALTER TABLE invoices DROP COLUMN IF EXISTS invoice_type;
ALTER TABLE invoices DROP COLUMN IF EXISTS currency;
