CREATE TABLE blc_credit_account (id VARCHAR(36) NOT NULL, account_number VARCHAR(60) NULL, balance DECIMAL(19, 5) DEFAULT NULL NULL, currency VARCHAR(255) NULL, owning_user_ref VARCHAR(60) NULL, owning_user_type VARCHAR(60) 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, CONSTRAINT PK_BLC_CREDIT_ACCOUNT PRIMARY KEY (id));
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_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));
CREATE TABLE blc_transaction (id VARCHAR(36) NOT NULL, amount DECIMAL(19, 5) DEFAULT NULL NULL, date_recorded datetime DEFAULT NULL NULL, reason VARCHAR(500) NULL, reason_description LONGTEXT NULL, request_id VARCHAR(255) NULL, source VARCHAR(255) NULL, source_entity_id VARCHAR(36) NULL, source_entity_type VARCHAR(60) NULL, source_user_id VARCHAR(36) NULL, source_user_type VARCHAR(60) 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, credit_account_id VARCHAR(36) NOT NULL, CONSTRAINT PK_BLC_TRANSACTION PRIMARY KEY (id));
ALTER TABLE blc_resource_lock ADD CONSTRAINT UK7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
ALTER TABLE blc_transaction ADD CONSTRAINT FKkpucbcmxk6j1ci1dnpqjosf9b FOREIGN KEY (credit_account_id) REFERENCES blc_credit_account (id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE blc_credit_account ADD version INT NOT NULL;
