CREATE TABLE blc_notification_state (id VARCHAR(36) NOT NULL, acked CHAR(1) DEFAULT 'N' NOT NULL, attempts INT DEFAULT NULL NULL, change_timestamp datetime DEFAULT NULL NULL, change_timestamp_ack datetime DEFAULT NULL NULL, container VARCHAR(36) NULL, entity_type VARCHAR(255) NOT NULL, message_type VARCHAR(255) NULL, message_value LONGTEXT NULL, notification_name VARCHAR(255) NULL, next_attempt datetime DEFAULT NULL NULL, stopped CHAR(1) DEFAULT 'N' NOT NULL, CONSTRAINT PK_BLC_NOTIFICATION_STATE PRIMARY KEY (id));
CREATE TABLE blc_payment (id VARCHAR(36) NOT NULL, addresses LONGTEXT NULL, adjustments_total DECIMAL(19, 5) DEFAULT NULL NULL, amount DECIMAL(19, 5) DEFAULT NULL NULL, attributes LONGTEXT NULL, saved_payment_method_id VARCHAR(255) NULL, display_attributes LONGTEXT NULL, fulfillment_total DECIMAL(19, 5) DEFAULT NULL NULL, gateway_type VARCHAR(60) NULL, single_use_payment_method CHAR(1) DEFAULT 'N' NOT NULL, name VARCHAR(255) NULL, owner_id VARCHAR(36) NULL, owner_type VARCHAR(60) NULL, payment_method_properties LONGTEXT NULL, should_save_pmt_to_customer CHAR(1) DEFAULT 'N' NOT NULL, subtotal DECIMAL(19, 5) DEFAULT NULL NULL, tax_total DECIMAL(19, 5) DEFAULT NULL NULL, trk_archived CHAR(1) DEFAULT 'N' NOT NULL, audit_creation_time datetime DEFAULT NULL NULL, audit_creator VARCHAR(60) NULL, audit_update_time datetime DEFAULT NULL NULL, audit_updater VARCHAR(60) NULL, trk_change_details LONGTEXT NULL, trk_tenant_id VARCHAR(36) NULL, type VARCHAR(60) NULL, version INT NOT NULL, CONSTRAINT PK_BLC_PAYMENT PRIMARY KEY (id));
CREATE TABLE blc_payment_transaction (id VARCHAR(36) NOT NULL, amount DECIMAL(19, 5) DEFAULT NULL NULL, attributes LONGTEXT NULL, customer_ip_address VARCHAR(255) NULL, date_recorded datetime DEFAULT NULL NULL, decline_type VARCHAR(60) NULL, failure_type VARCHAR(60) NULL, gateway_response_code VARCHAR(255) NULL, indeterminate_result CHAR(1) DEFAULT 'N' NOT NULL, management_state VARCHAR(60) NULL, parent_transaction_id VARCHAR(36) NULL, raw_response LONGTEXT NULL, request_id VARCHAR(255) NULL, source VARCHAR(255) NULL, status VARCHAR(60) NULL, three_d_sec_verification_url VARCHAR(500) NULL, trk_archived CHAR(1) DEFAULT 'N' NOT NULL, audit_creation_time datetime DEFAULT NULL NULL, audit_creator VARCHAR(60) NULL, audit_update_time datetime DEFAULT NULL NULL, audit_updater VARCHAR(60) NULL, trk_change_details LONGTEXT NULL, trk_tenant_id VARCHAR(36) NULL, transaction_reference_id VARCHAR(255) NULL, type VARCHAR(60) NULL, version INT NOT NULL, payment_id VARCHAR(36) NOT NULL, CONSTRAINT PK_BLC_PAYMENT_TRANSACTION PRIMARY KEY (id));
CREATE TABLE blc_resource_lock (id VARCHAR(36) NOT NULL, concept_key VARCHAR(255) NULL, context_id VARCHAR(36) NULL, lock_expiration_timestamp datetime DEFAULT NULL NULL, `locked` CHAR(1) DEFAULT 'N' NULL, sandbox_id VARCHAR(36) NULL, lock_timestamp datetime DEFAULT NULL NULL, token VARCHAR(255) NULL, type_alias VARCHAR(255) NULL, CONSTRAINT PK_BLC_RESOURCE_LOCK PRIMARY KEY (id));
ALTER TABLE blc_resource_lock ADD CONSTRAINT UK7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
CREATE INDEX FKeqnspi0p8wrsjjrgxovtc4m5c ON blc_payment_transaction(payment_id);
CREATE INDEX IDX7i0i5vcl1dkkwuq5dyc88wem5 ON blc_notification_state(acked);
CREATE INDEX IDXgfaqe3xmq5q4yh78mix1g04fy ON blc_notification_state(container);
CREATE INDEX IDXkm4y3qj3jh2mpt0rt6l6vscl8 ON blc_resource_lock(token);
CREATE INDEX IDXmb5ixjylopr5dwig7jehaouae ON blc_payment(owner_id);
ALTER TABLE blc_payment_transaction ADD CONSTRAINT FKeqnspi0p8wrsjjrgxovtc4m5c FOREIGN KEY (payment_id) REFERENCES blc_payment (id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE blc_payment_transaction ADD gateway_transaction_type VARCHAR(60) NULL;
ALTER TABLE blc_payment_transaction ADD parent_source_entity_id VARCHAR(36) NULL;
ALTER TABLE blc_payment_transaction ADD parent_source_entity_type VARCHAR(60) NULL;
ALTER TABLE blc_payment_transaction ADD source_entity_id VARCHAR(36) NULL;
ALTER TABLE blc_payment_transaction ADD source_entity_type VARCHAR(60) NULL;
ALTER TABLE blc_payment ADD customer_id VARCHAR(36) NULL;
ALTER TABLE blc_payment ADD is_customer_registered CHAR(1) DEFAULT 'N' NULL;
ALTER TABLE blc_payment ADD access_restrictions LONGTEXT NULL;
ALTER TABLE blc_payment ADD currency VARCHAR(255) NULL;
