CREATE TABLE blc_payment_transaction (id VARCHAR(36) NOT NULL, amount numeric(19, 5), attributes VARCHAR(10485760), customer_ip_address VARCHAR(255), date_recorded TIMESTAMP WITHOUT TIME ZONE, decline_type VARCHAR(60), failure_type VARCHAR(60), gateway_response_code VARCHAR(255), indeterminate_result CHAR(1) DEFAULT 'N' NOT NULL, management_state VARCHAR(60), parent_transaction_id VARCHAR(36), raw_response VARCHAR(10485760), request_id VARCHAR(255), source VARCHAR(255), status VARCHAR(60), three_d_sec_verification_url VARCHAR(500), 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), transaction_reference_id VARCHAR(255), type VARCHAR(60), version INTEGER NOT NULL, payment_id VARCHAR(36) NOT NULL, CONSTRAINT blc_payment_transaction_pkey PRIMARY KEY (id));
CREATE TABLE blc_notification_state (id VARCHAR(36) NOT NULL, acked CHAR(1) DEFAULT 'N' NOT NULL, attempts INTEGER, change_timestamp TIMESTAMP WITHOUT TIME ZONE, change_timestamp_ack TIMESTAMP WITHOUT TIME ZONE, container VARCHAR(36), entity_type VARCHAR(255) NOT NULL, message_type VARCHAR(255), message_value VARCHAR(10485760), notification_name VARCHAR(255), next_attempt TIMESTAMP WITHOUT TIME ZONE, stopped CHAR(1) DEFAULT 'N' NOT NULL, CONSTRAINT blc_notification_state_pkey PRIMARY KEY (id));
CREATE TABLE blc_payment (id VARCHAR(36) NOT NULL, addresses VARCHAR(10485760), adjustments_total numeric(19, 5), amount numeric(19, 5), attributes VARCHAR(10485760), saved_payment_method_id VARCHAR(255), display_attributes VARCHAR(10485760), fulfillment_total numeric(19, 5), gateway_type VARCHAR(60), single_use_payment_method CHAR(1) DEFAULT 'N' NOT NULL, name VARCHAR(255), owner_id VARCHAR(36), owner_type VARCHAR(60), payment_method_properties VARCHAR(10485760), should_save_pmt_to_customer CHAR(1) DEFAULT 'N' NOT NULL, subtotal numeric(19, 5), tax_total numeric(19, 5), 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_payment_pkey PRIMARY KEY (id));
CREATE TABLE blc_resource_lock (id VARCHAR(36) NOT NULL, concept_key VARCHAR(255), context_id VARCHAR(36), lock_expiration_timestamp TIMESTAMP WITHOUT TIME ZONE, locked CHAR(1) DEFAULT 'N', sandbox_id VARCHAR(36), lock_timestamp TIMESTAMP WITHOUT TIME ZONE, token VARCHAR(255), type_alias VARCHAR(255), CONSTRAINT blc_resource_lock_pkey PRIMARY KEY (id));
CREATE INDEX fkeqnspi0p8wrsjjrgxovtc4m5c_idx ON blc_payment_transaction(payment_id);
CREATE INDEX idx7i0i5vcl1dkkwuq5dyc88wem5 ON blc_notification_state(acked);
CREATE INDEX idxgfaqe3xmq5q4yh78mix1g04fy ON blc_notification_state(container);
ALTER TABLE blc_payment_transaction ADD CONSTRAINT fkeqnspi0p8wrsjjrgxovtc4m5c FOREIGN KEY (payment_id) REFERENCES blc_payment (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
CREATE INDEX idxmb5ixjylopr5dwig7jehaouae ON blc_payment(owner_id);
CREATE INDEX idxkm4y3qj3jh2mpt0rt6l6vscl8 ON blc_resource_lock(token);
ALTER TABLE blc_resource_lock ADD CONSTRAINT uk7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
ALTER TABLE blc_payment_transaction ADD gateway_transaction_type VARCHAR(60);
ALTER TABLE blc_payment_transaction ADD parent_source_entity_id VARCHAR(36);
ALTER TABLE blc_payment_transaction ADD parent_source_entity_type VARCHAR(60);
ALTER TABLE blc_payment_transaction ADD source_entity_id VARCHAR(36);
ALTER TABLE blc_payment_transaction ADD source_entity_type VARCHAR(60);
ALTER TABLE blc_payment ADD customer_id VARCHAR(36);
ALTER TABLE blc_payment ADD is_customer_registered CHAR(1) DEFAULT 'N';
ALTER TABLE blc_payment ADD access_restrictions VARCHAR(65535);
ALTER TABLE blc_payment ALTER COLUMN access_restrictions TYPE VARCHAR(10485760) USING (access_restrictions::VARCHAR(10485760));
ALTER TABLE blc_payment ADD currency VARCHAR(255);
