CREATE TABLE blc_application (id VARCHAR(36) NOT NULL, allowed_currencies VARCHAR(10485760), allowed_locales VARCHAR(10485760), deactivated CHAR(1) DEFAULT 'N' NOT NULL, default_currency VARCHAR(255), default_locale VARCHAR(255), identifier_type VARCHAR(60), identifier_value VARCHAR(255), is_marketplace CHAR(1) DEFAULT 'N' NOT NULL, name VARCHAR(255), updated_timestamp TIMESTAMP WITHOUT TIME ZONE, 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), CONSTRAINT blc_application_pkey PRIMARY KEY (id));
CREATE TABLE blc_application_catalog (application_id VARCHAR(36) NOT NULL, catalog_status VARCHAR(60), context_id VARCHAR(36), exclude_from_add CHAR(1) DEFAULT 'N' NOT NULL, implicit VARCHAR(36), mutability_type VARCHAR(60), visible_as_assigned CHAR(1) DEFAULT 'Y' NOT NULL, isolated_catalogs_order INTEGER NOT NULL, CONSTRAINT blc_application_catalog_pkey PRIMARY KEY (application_id, isolated_catalogs_order));
CREATE TABLE blc_cart (id VARCHAR(36) NOT NULL, adjustments VARCHAR(10485760), adjustments_total numeric(19, 5), attribute_choices VARCHAR(10485760), attributes VARCHAR(10485760), campaigns VARCHAR(10485760), cart_items VARCHAR(10485760), checkout_submissions VARCHAR(10485760), create_date TIMESTAMP WITHOUT TIME ZONE, currency VARCHAR(255), customer_id VARCHAR(36), email_address VARCHAR(255), fulfillment_groups VARCHAR(10485760), total_shipping numeric(19, 5), full_name VARCHAR(255), internal_attributes VARCHAR(10485760), is_priced CHAR(1) DEFAULT 'N' NOT NULL, is_registered CHAR(1) DEFAULT 'N', is_tax_estimated CHAR(1) DEFAULT 'Y' NOT NULL, last_catalog_reprice TIMESTAMP WITHOUT TIME ZONE, locale VARCHAR(255), name VARCHAR(255), offer_codes VARCHAR(65535), order_number VARCHAR(255), status VARCHAR(60), submit_date TIMESTAMP WITHOUT TIME ZONE, subtotal numeric(19, 5), total numeric(19, 5), total_tax numeric(19, 5), trk_application_context_id VARCHAR(36), trk_application_default_locale VARCHAR(255), trk_application_name VARCHAR(255), 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_creating_application_id VARCHAR(36), trk_current_message VARCHAR(255), trk_level INTEGER, trk_max_field_versions VARCHAR(10485760), trk_sandbox_archived CHAR(1) DEFAULT 'N' NOT NULL, trk_sub_container_catalog VARCHAR(36), trk_change_container_id VARCHAR(36), trk_change_container_name VARCHAR(255), trk_change_container_route_key VARCHAR(60), trk_sub_container_name VARCHAR(255), trk_sandbox_change_type VARCHAR(60), trk_sandbox_context_id VARCHAR(36), trk_sandbox_name VARCHAR(255), trk_sandbox_owner VARCHAR(60), trk_sandbox_stage VARCHAR(60), trk_tenant_id VARCHAR(36), username VARCHAR(255), version INTEGER NOT NULL, vouchers VARCHAR(10485760), CONSTRAINT blc_cart_pkey PRIMARY KEY (id));
CREATE TABLE blc_guest_token (cart_id VARCHAR(36) NOT NULL, expiration_time TIMESTAMP WITHOUT TIME ZONE, token_string VARCHAR(255), trk_application_context_id VARCHAR(36), trk_application_default_locale VARCHAR(255), trk_application_name VARCHAR(255), 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_creating_application_id VARCHAR(36), trk_customer_context_id VARCHAR(36), trk_tenant_id VARCHAR(36), CONSTRAINT blc_guest_token_pkey PRIMARY KEY (cart_id));
CREATE TABLE blc_item_list (id VARCHAR(36) NOT NULL, attributes VARCHAR(10485760), name VARCHAR(255), trk_application_context_id VARCHAR(36), trk_application_default_locale VARCHAR(255), trk_application_name VARCHAR(255), 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_creating_application_id VARCHAR(36), trk_customer_context_id VARCHAR(36), trk_tenant_id VARCHAR(36), CONSTRAINT blc_item_list_pkey PRIMARY KEY (id));
CREATE TABLE blc_item_list_access_rule (id VARCHAR(36) NOT NULL, item_list_id VARCHAR(36) NOT NULL, role VARCHAR(60) NOT NULL, trk_application_context_id VARCHAR(36), trk_application_default_locale VARCHAR(255), trk_application_name VARCHAR(255), 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_creating_application_id VARCHAR(36), trk_customer_context_id VARCHAR(36), trk_tenant_id VARCHAR(36), type VARCHAR(60) NOT NULL, value VARCHAR(255) NOT NULL, CONSTRAINT blc_item_list_access_rule_pkey PRIMARY KEY (id));
CREATE TABLE blc_item_list_item (id VARCHAR(36) NOT NULL, attribute_choices VARCHAR(10485760), attributes VARCHAR(10485760), internal_attributes VARCHAR(10485760), item_list_id VARCHAR(255), ref_product_id VARCHAR(255), quantity INTEGER, ref_sku VARCHAR(255), trk_application_context_id VARCHAR(36), trk_application_default_locale VARCHAR(255), trk_application_name VARCHAR(255), 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_creating_application_id VARCHAR(36), trk_customer_context_id VARCHAR(36), trk_tenant_id VARCHAR(36), ref_variant_id VARCHAR(255), CONSTRAINT blc_item_list_item_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));
ALTER TABLE blc_resource_lock ADD CONSTRAINT uk7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
ALTER TABLE blc_application_catalog ADD CONSTRAINT fkdaeorqo87oh0rdu1lfkpv3qow FOREIGN KEY (application_id) REFERENCES blc_application (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
