CREATE TABLE blc_application (id VARCHAR(36) NOT NULL, allowed_currencies LONGTEXT NULL, allowed_locales LONGTEXT NULL, deactivated CHAR(1) DEFAULT 'N' NOT NULL, default_currency VARCHAR(255) NULL, default_locale VARCHAR(255) NULL, identifier_type VARCHAR(60) NULL, identifier_value VARCHAR(255) NULL, name VARCHAR(255) NULL, updated_timestamp datetime NULL, trk_archived CHAR(1) DEFAULT 'N' NOT NULL, trk_change_details LONGTEXT NULL, trk_tenant_id VARCHAR(36) NULL, CONSTRAINT PK_BLC_APPLICATION PRIMARY KEY (id));
CREATE TABLE blc_application_catalog (application_id VARCHAR(36) NOT NULL, catalog_status VARCHAR(60) NULL, context_id VARCHAR(36) NULL, exclude_from_add CHAR(1) DEFAULT 'N' NOT NULL, implicit VARCHAR(36) NULL, mutability_type VARCHAR(60) NULL, visible_as_assigned CHAR(1) DEFAULT 'Y' NOT NULL, isolated_catalogs_order INT NOT NULL, CONSTRAINT PK_BLC_APPLICATION_CATALOG PRIMARY KEY (application_id, isolated_catalogs_order));
CREATE TABLE blc_catalog (id VARCHAR(36) NOT NULL, default_currency VARCHAR(255) NULL, hidden CHAR(1) DEFAULT 'N' NOT NULL, catalog_level BIGINT NULL, catalog_locale VARCHAR(255) NULL, catalog_name VARCHAR(255) NULL, owning_application VARCHAR(36) NULL, updated_timestamp datetime NULL, trk_archived CHAR(1) DEFAULT 'N' NOT NULL, trk_change_details LONGTEXT NULL, trk_tenant_id VARCHAR(36) NULL, vendor_ref VARCHAR(255) NULL, CONSTRAINT PK_BLC_CATALOG PRIMARY KEY (id));
CREATE TABLE blc_catalog_ref (id VARCHAR(36) NOT NULL, exclusion_filters LONGTEXT NULL, inclusion_filters LONGTEXT NULL, mutability_type VARCHAR(60) NULL, parent_catalog_id VARCHAR(36) NULL, child_catalog_id VARCHAR(36) NOT NULL, parents_order INT NULL, CONSTRAINT PK_BLC_CATALOG_REF PRIMARY KEY (id));
CREATE TABLE blc_change_deploy (id VARCHAR(36) NOT NULL, application VARCHAR(36) NULL, archived CHAR(1) DEFAULT 'N' NOT NULL, author VARCHAR(255) NULL, group_ids LONGTEXT NULL, date_created datetime NULL, date_scheduled datetime NULL, deploy_message VARCHAR(255) NULL, display_name VARCHAR(255) NULL, deploy_exception LONGTEXT NULL, tracking_level INT NULL, sandbox VARCHAR(36) NULL, state VARCHAR(60) NULL, status VARCHAR(60) NULL, status_change_time datetime NULL, CONSTRAINT PK_BLC_CHANGE_DEPLOY PRIMARY KEY (id));
CREATE TABLE blc_change_summary (id VARCHAR(36) NOT NULL, archived CHAR(1) DEFAULT 'N' NOT NULL, author VARCHAR(60) NULL, trk_change_details LONGTEXT NULL, trk_field_overrides LONGTEXT NULL, trk_max_field_versions LONGTEXT NULL, trk_application_context_id VARCHAR(36) NULL, trk_application_default_locale VARCHAR(255) NULL, trk_application_name VARCHAR(255) NULL, trk_archived CHAR(1) DEFAULT 'N' NOT NULL, trk_catalog_context_id VARCHAR(36) NULL, trk_catalog_level BIGINT NULL, trk_catalog_locale VARCHAR(255) NULL, trk_catalog_name VARCHAR(255) NULL, trk_parent_cat_context_id VARCHAR(36) NULL, trk_parent_cat_level BIGINT NULL, trk_parent_cat_locale VARCHAR(255) NULL, trk_parent_cat_name VARCHAR(255) NULL, trk_creating_application_id VARCHAR(36) NULL, trk_current_message VARCHAR(255) NULL, trk_level INT NULL, trk_sandbox_archived CHAR(1) DEFAULT 'N' NOT NULL, trk_sub_container_catalog VARCHAR(36) NULL, trk_change_container_id VARCHAR(36) NULL, trk_change_container_name VARCHAR(255) NULL, trk_change_container_route_key VARCHAR(60) NULL, trk_sub_container_name VARCHAR(255) NULL, trk_sandbox_change_type VARCHAR(60) NULL, trk_sandbox_context_id VARCHAR(36) NULL, trk_sandbox_name VARCHAR(255) NULL, trk_sandbox_owner VARCHAR(60) NULL, trk_sandbox_stage VARCHAR(60) NULL, trk_tenant_id VARCHAR(36) NULL, display_name VARCHAR(255) NULL, domain_alias VARCHAR(60) NULL, domain_context_id VARCHAR(36) NULL, entity_type VARCHAR(255) NULL, transition_exception LONGTEXT NULL, indexable_processed CHAR(1) DEFAULT 'N' NOT NULL, indexable_target_id VARCHAR(36) NULL, indexable_type VARCHAR(60) NULL, promotion_id VARCHAR(36) NULL, reject_message VARCHAR(255) NULL, sandbox VARCHAR(36) NULL, state VARCHAR(60) NULL, status VARCHAR(60) NULL, status_change_time datetime NULL, CONSTRAINT PK_BLC_CHANGE_SUMMARY PRIMARY KEY (id));
CREATE TABLE blc_change_summary_group (id VARCHAR(36) NOT NULL, archived CHAR(1) DEFAULT 'N' NOT NULL, author VARCHAR(255) NULL, summary_ids LONGTEXT NULL, deployment_date datetime NULL, display_name VARCHAR(255) NULL, transition_exception LONGTEXT NULL, promote_message VARCHAR(255) NULL, sandbox VARCHAR(36) NULL, state VARCHAR(60) NULL, status VARCHAR(60) NULL, change_status_time datetime NULL, CONSTRAINT PK_BLC_CHANGE_SUMMARY_GROUP PRIMARY KEY (id));
CREATE TABLE blc_notification_state (id VARCHAR(36) NOT NULL, acked CHAR(1) DEFAULT 'N' NOT NULL, attempts INT NULL, change_timestamp datetime NULL, change_timestamp_ack datetime 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 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 NULL, `locked` CHAR(1) DEFAULT 'N' NULL, sandbox_id VARCHAR(36) NULL, lock_timestamp datetime NULL, token VARCHAR(255) NULL, type_alias VARCHAR(255) NULL, CONSTRAINT PK_BLC_RESOURCE_LOCK PRIMARY KEY (id));
CREATE TABLE blc_sandbox (id VARCHAR(36) NOT NULL, application VARCHAR(36) NULL, color VARCHAR(255) NULL, `description` VARCHAR(255) NULL, name VARCHAR(255) NULL, trk_archived CHAR(1) DEFAULT 'N' NOT NULL, trk_change_details LONGTEXT NULL, trk_tenant_id VARCHAR(36) NULL, CONSTRAINT PK_BLC_SANDBOX PRIMARY KEY (id));
ALTER TABLE blc_resource_lock ADD CONSTRAINT UK7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
CREATE INDEX FKqa2huaj7r3r8ovdilb9h71x2k ON blc_catalog_ref(child_catalog_id);
CREATE INDEX IDX1fi9wnq6ewrubid3npnnyqx8l ON blc_sandbox(application);
CREATE INDEX IDX4yhqvpe4g6ryvpwh87wskv1ru ON blc_change_summary_group(sandbox, state);
CREATE INDEX IDX5padhspwpecyv5ub42ytumell ON blc_change_summary(domain_context_id, domain_alias, entity_type, author, sandbox);
CREATE INDEX IDX7i0i5vcl1dkkwuq5dyc88wem5 ON blc_notification_state(acked);
CREATE INDEX IDXf8yv5lwyf62ifctb6h19b8ks8 ON blc_sandbox(name);
CREATE INDEX IDXgfaqe3xmq5q4yh78mix1g04fy ON blc_notification_state(container);
CREATE INDEX IDXh32lne3ixbepvh5rr6eekpdqu ON blc_change_summary(author, sandbox);
CREATE INDEX IDXihvg4sxhg7vy2wabgxxbw5hms ON blc_change_deploy(application, state);
CREATE INDEX IDXkm4y3qj3jh2mpt0rt6l6vscl8 ON blc_resource_lock(token);
CREATE INDEX IDXlj2n3wdt6u930s8c5g28hh0yr ON blc_application_catalog(application_id);
CREATE INDEX IDXosj785tkew6sxuw6sd26k70qk ON blc_application_catalog(context_id);
ALTER TABLE blc_application_catalog ADD CONSTRAINT FKdaeorqo87oh0rdu1lfkpv3qow FOREIGN KEY (application_id) REFERENCES blc_application (id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE blc_catalog_ref ADD CONSTRAINT FKqa2huaj7r3r8ovdilb9h71x2k FOREIGN KEY (child_catalog_id) REFERENCES blc_catalog (id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE blc_change_summary ADD transition_marker VARCHAR(36) NULL;
CREATE INDEX IDXn16c4rpnhkdt18cxe83yy6s9w ON blc_change_summary(transition_marker);
ALTER TABLE blc_change_summary ADD remove_temp_override CHAR(1) DEFAULT 'N' NOT NULL;
ALTER TABLE blc_sandbox ADD temporary_sandbox CHAR(1) DEFAULT 'N' NOT NULL;
CREATE INDEX IDX1swm3w6cwnt8gvt8mad3ctbqn ON blc_catalog(owning_application);
CREATE INDEX IDXo9ysroyx17nrb02mef9qf3qjl ON blc_catalog(vendor_ref);
CREATE TABLE blc_change_deploy_vendor_xref (change_deploy_id VARCHAR(255) NOT NULL, vendor_ref VARCHAR(255) NOT NULL, CONSTRAINT PK_BLC_CHANGE_DEPLOY_VENDOR_XREF PRIMARY KEY (change_deploy_id, vendor_ref));
CREATE TABLE blc_change_group_vendor_xref (change_group_id VARCHAR(255) NOT NULL, vendor_ref VARCHAR(255) NOT NULL, CONSTRAINT PK_BLC_CHANGE_GROUP_VENDOR_XREF PRIMARY KEY (change_group_id, vendor_ref));
ALTER TABLE blc_change_deploy ADD affects_non_vendor_data CHAR(1) DEFAULT 'N' NOT NULL;
ALTER TABLE blc_change_summary_group ADD affects_non_vendor_data CHAR(1) DEFAULT 'N' NOT NULL;
ALTER TABLE blc_change_summary ADD vendor_ref VARCHAR(255) NULL;
ALTER TABLE blc_change_group_vendor_xref ADD CONSTRAINT FKivhr0sdt80uusipvyidw5btb3 FOREIGN KEY (change_group_id) REFERENCES blc_change_summary_group (id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE blc_change_deploy_vendor_xref ADD CONSTRAINT FKpib48x6689981wh37um18g7mx FOREIGN KEY (change_deploy_id) REFERENCES blc_change_deploy (id) ON UPDATE RESTRICT ON DELETE RESTRICT;
