ALTER TABLE sale_line_items ADD COLUMN recurly_adjustment_uuid VARCHAR(500);
ALTER TABLE sale_line_items ADD COLUMN recurly_adjustment_credit_uuid  VARCHAR(500);
ALTER TABLE jam_track_rights ADD COLUMN recurly_adjustment_uuid VARCHAR(500);
ALTER TABLE jam_track_rights ADD COLUMN recurly_adjustment_credit_uuid VARCHAR(500);
ALTER TABLE sales ADD COLUMN recurly_invoice_id VARCHAR(500) UNIQUE;
ALTER TABLE sales ADD COLUMN recurly_invoice_number INTEGER;

ALTER TABLE sales ADD COLUMN recurly_subtotal_in_cents INTEGER;
ALTER TABLE sales ADD COLUMN recurly_tax_in_cents INTEGER;
ALTER TABLE sales ADD COLUMN recurly_total_in_cents INTEGER;
ALTER TABLE sales ADD COLUMN recurly_currency VARCHAR;

ALTER TABLE sale_line_items ADD COLUMN recurly_tax_in_cents INTEGER;
ALTER TABLE sale_line_items ADD COLUMN recurly_total_in_cents INTEGER;
ALTER TABLE sale_line_items ADD COLUMN recurly_currency VARCHAR;
ALTER TABLE sale_line_items ADD COLUMN recurly_discount_in_cents INTEGER;

ALTER TABLE sales ADD COLUMN sale_type VARCHAR NOT NULL DEFAULT 'jamtrack';

ALTER TABLE recurly_transaction_web_hooks ALTER COLUMN subscription_id DROP NOT NULL;

CREATE INDEX recurly_transaction_web_hooks_invoice_id_ndx ON recurly_transaction_web_hooks(invoice_id);

ALTER TABLE jam_track_rights DROP COLUMN recurly_subscription_uuid;