ALTER TABLE blc_payment_transaction ADD gateway_message VARCHAR(500);
ALTER TABLE blc_payment_transaction ADD gateway_transaction_id VARCHAR(255);
CREATE TABLE blc_saved_payment_method (id VARCHAR(36) NOT NULL, attributes VARCHAR(10485760), billing_address VARCHAR(10485760), is_default_for_owner CHAR(1) DEFAULT 'N', display_attributes VARCHAR(10485760), gateway_type VARCHAR(60), last_tx_date_time TIMESTAMP WITHOUT TIME ZONE, last_tx_result_code VARCHAR(255), name VARCHAR(255), originating_payment_id VARCHAR(36), owning_user_id VARCHAR(36), owning_user_type VARCHAR(60), payment_method_properties VARCHAR(10485760), trk_archived CHAR(1) DEFAULT 'N' NOT NULL, audit_creation_time TIMESTAMP WITHOUT TIME ZONE, audit_creator VARCHAR(60), audit_update_time TIMESTAMP WITHOUT TIME ZONE, audit_updater VARCHAR(60), trk_change_details VARCHAR(10485760), trk_tenant_id VARCHAR(36), type VARCHAR(60), version INTEGER NOT NULL, CONSTRAINT blc_saved_payment_method_pkey PRIMARY KEY (id));
ALTER TABLE blc_payment ADD owning_user_id VARCHAR(36);
ALTER TABLE blc_payment ADD owning_user_type VARCHAR(60);
UPDATE blc_payment SET owning_user_type = CASE WHEN is_customer_registered = 'Y' THEN 'BLC_CUSTOMER' WHEN is_customer_registered = 'N' THEN 'ANONYMOUS' END, owning_user_id = CASE WHEN is_customer_registered = 'Y' THEN customer_id WHEN is_customer_registered = 'N' THEN NULL END;
ALTER TABLE blc_payment ADD should_save_pmt_for_future_use CHAR(1) DEFAULT 'N' NOT NULL;
UPDATE blc_payment SET should_save_pmt_for_future_use = should_save_pmt_to_customer;
ALTER TABLE blc_payment_transaction ADD management_state_reason VARCHAR(60);
ALTER TABLE blc_payment_transaction ADD previous_request_ids VARCHAR(65535);
