CREATE TABLE blc_credit_account (id VARCHAR(36) NOT NULL, account_number VARCHAR(60), balance numeric(19, 5), currency VARCHAR(255), owning_user_ref VARCHAR(60), owning_user_type VARCHAR(60), 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), CONSTRAINT blc_credit_account_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_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_transaction (id VARCHAR(36) NOT NULL, amount numeric(19, 5), date_recorded TIMESTAMP WITHOUT TIME ZONE, reason VARCHAR(500), reason_description VARCHAR(10485760), request_id VARCHAR(255), source VARCHAR(255), source_entity_id VARCHAR(36), source_entity_type VARCHAR(60), source_user_id VARCHAR(36), source_user_type VARCHAR(60), 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), credit_account_id VARCHAR(36) NOT NULL, CONSTRAINT blc_transaction_pkey 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 NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_credit_account ADD version INTEGER NOT NULL;
