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, access_restrictions VARCHAR(10485760), addresses VARCHAR(10485760), adjustments_total numeric(19, 5), amount numeric(19, 5), attributes VARCHAR(10485760), currency VARCHAR(255), customer_id VARCHAR(36), display_attributes VARCHAR(10485760), fulfillment_total numeric(19, 5), gateway_type VARCHAR(60), is_customer_registered CHAR(1) DEFAULT 'N', single_use_payment_method CHAR(1) DEFAULT 'N' NOT NULL, name VARCHAR(255), owner_id VARCHAR(36), owner_type VARCHAR(60), owning_user_id VARCHAR(36), owning_user_type VARCHAR(60), payment_method_properties VARCHAR(10485760), saved_payment_method_id VARCHAR(255), should_save_pmt_for_future_use CHAR(1) DEFAULT 'N' NOT NULL, 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_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_message VARCHAR(500), gateway_response_code VARCHAR(255), gateway_transaction_id VARCHAR(255), gateway_transaction_type VARCHAR(60), indeterminate_result CHAR(1) DEFAULT 'N' NOT NULL, management_state VARCHAR(60), management_state_reason VARCHAR(60), parent_source_entity_id VARCHAR(36), parent_source_entity_type VARCHAR(60), parent_transaction_id VARCHAR(36), previous_request_ids VARCHAR(65535), raw_response VARCHAR(10485760), request_id VARCHAR(255), source VARCHAR(255), source_entity_id VARCHAR(36), source_entity_type VARCHAR(60), 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_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 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_resource_lock ADD CONSTRAINT uk7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
ALTER TABLE blc_payment_transaction ADD CONSTRAINT fkeqnspi0p8wrsjjrgxovtc4m5c FOREIGN KEY (payment_id) REFERENCES blc_payment (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
