CREATE TABLE blc_account (id VARCHAR(36) NOT NULL, account_number VARCHAR(255), account_type VARCHAR(255), attributes VARCHAR(10485760), name VARCHAR(255), parent_account_id VARCHAR(36), status VARCHAR(255), tax_id 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_account_pkey PRIMARY KEY (id));
CREATE TABLE blc_account_address (id VARCHAR(36) NOT NULL, addl_attributes VARCHAR(10485760), address_line_1 VARCHAR(255), address_line_2 VARCHAR(255), address_line_3 VARCHAR(255), city VARCHAR(255), company_name VARCHAR(255), country VARCHAR(255), county VARCHAR(255), email VARCHAR(255), first_name VARCHAR(255), full_name VARCHAR(255), active CHAR(1) DEFAULT 'Y' NOT NULL, is_default CHAR(1) DEFAULT 'N' NOT NULL, last_name VARCHAR(255), name VARCHAR(255), phone_fax VARCHAR(255), phone_primary VARCHAR(255), phone_secondary VARCHAR(255), postal_code VARCHAR(60), state_province_region VARCHAR(60), 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(255), account_id VARCHAR(36) NOT NULL, CONSTRAINT blc_account_address_pkey PRIMARY KEY (id));
CREATE TABLE blc_account_member (id VARCHAR(36) NOT NULL, additional_phones VARCHAR(65535), attributes VARCHAR(65535), email VARCHAR(255), phone 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), account_id VARCHAR(36) NOT NULL, customer_id VARCHAR(36) NOT NULL, account_role_id VARCHAR(36) NOT NULL, CONSTRAINT blc_account_member_pkey PRIMARY KEY (id));
CREATE TABLE blc_account_permission (id VARCHAR(36) NOT NULL, 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_account_permission_pkey PRIMARY KEY (id));
CREATE TABLE blc_account_role (id VARCHAR(36) NOT NULL, name VARCHAR(255), parent_role_id 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_account_role_pkey PRIMARY KEY (id));
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_bulk_update (id VARCHAR(36) NOT NULL, errors VARCHAR(10485760), application_id VARCHAR(36), author VARCHAR(255), created TIMESTAMP WITHOUT TIME ZONE, exclusions VARCHAR(10485760), filter_string VARCHAR(65535), inclusions VARCHAR(10485760), last_updated TIMESTAMP WITHOUT TIME ZONE, name VARCHAR(255), number_of_records_processed BIGINT, production_bulk_update CHAR(1) DEFAULT 'N' NOT NULL, serialized_payload VARCHAR(10485760), status VARCHAR(60), target VARCHAR(60), tenant_id VARCHAR(36), total_records_to_process BIGINT, type VARCHAR(60), updating_application_id VARCHAR(36), updating_catalog_id VARCHAR(36), updating_customer_context_id VARCHAR(36), updating_sandbox_id VARCHAR(36), updating_sandbox_name VARCHAR(255), CONSTRAINT blc_bulk_update_pkey PRIMARY KEY (id));
CREATE TABLE blc_customer (id VARCHAR(36) NOT NULL, active CHAR(1) DEFAULT 'Y', additional_phones VARCHAR(65535), attributes VARCHAR(65535), default_payment_account_id VARCHAR(255), email VARCHAR(255), external_id VARCHAR(255), first_name VARCHAR(255), full_name VARCHAR(255), last_name VARCHAR(255), locked CHAR(1) DEFAULT 'N', middle_name VARCHAR(255), phone VARCHAR(255), special_type VARCHAR(255), updated_timestamp TIMESTAMP WITHOUT TIME ZONE, 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), username VARCHAR(255), CONSTRAINT blc_customer_pkey PRIMARY KEY (id));
CREATE TABLE blc_customer_address (id VARCHAR(36) NOT NULL, addl_attributes VARCHAR(10485760), address_line_1 VARCHAR(255), address_line_2 VARCHAR(255), address_line_3 VARCHAR(255), city VARCHAR(255), company_name VARCHAR(255), country VARCHAR(255), county VARCHAR(255), customer_id VARCHAR(36) NOT NULL, is_default_billing CHAR(1) DEFAULT 'N' NOT NULL, is_default_shipping CHAR(1) DEFAULT 'N' NOT NULL, email VARCHAR(255), first_name VARCHAR(255), full_name VARCHAR(255), active CHAR(1) DEFAULT 'Y' NOT NULL, last_name VARCHAR(255), name VARCHAR(255), phone_fax VARCHAR(255), phone_primary VARCHAR(255), phone_secondary VARCHAR(255), postal_code VARCHAR(60), state_province_region VARCHAR(60), 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_customer_address_pkey PRIMARY KEY (id));
CREATE TABLE blc_customer_note (id VARCHAR(36) NOT NULL, author VARCHAR(255), created TIMESTAMP WITHOUT TIME ZONE NOT NULL, customer_id VARCHAR(36), note VARCHAR(65535), 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_customer_note_pkey PRIMARY KEY (id));
CREATE TABLE blc_customer_segment (id VARCHAR(36) NOT NULL, is_active CHAR(1) DEFAULT 'Y' NOT NULL, segment_type VARCHAR(60), description VARCHAR(255), name VARCHAR(255) NOT NULL, priority INTEGER, processing_state VARCHAR(60), segment_match_rule VARCHAR(65535), 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), CONSTRAINT blc_customer_segment_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_payment_account (id VARCHAR(36) NOT NULL, account_type VARCHAR(60), address_line_1 VARCHAR(255), address_line_2 VARCHAR(255), address_line_3 VARCHAR(255), card_type VARCHAR(60), city VARCHAR(255), country VARCHAR(255), county VARCHAR(255), customer_id VARCHAR(36) NOT NULL, deactivated CHAR(1) DEFAULT 'N' NOT NULL, display_attributes VARCHAR(10485760), display_name VARCHAR(255), exp_month INTEGER, exp_year INTEGER, full_name VARCHAR(255), gateway_type VARCHAR(60), last_transaction_date_time TIMESTAMP WITHOUT TIME ZONE, last_billing_transaction_result_code VARCHAR(255), masked_account_number VARCHAR(255), name_on_account VARCHAR(255), originating_payment_id VARCHAR(36), payment_gateway_properties VARCHAR(10485760), phone_primary VARCHAR(255), phone_secondary VARCHAR(255), postal_code VARCHAR(255), state_province_region VARCHAR(60), 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_payment_account_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_segment_bulk_process (id VARCHAR(36) NOT NULL, bulk_update_ctx_id VARCHAR(36), created_on TIMESTAMP WITHOUT TIME ZONE, cust_segment_ctx_id VARCHAR(36), 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_segment_bulk_process_pkey PRIMARY KEY (id));
CREATE TABLE blc_segment_member (id VARCHAR(36) NOT NULL, customer_segment_id VARCHAR(36), source VARCHAR(60), updated_timestamp TIMESTAMP WITHOUT TIME ZONE, 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), customer_id VARCHAR(36) NOT NULL, CONSTRAINT blc_segment_member_pkey PRIMARY KEY (id));
CREATE TABLE blc_account_role_account_permission_xref (account_role_id VARCHAR(36) NOT NULL, account_permission_id VARCHAR(36) NOT NULL, CONSTRAINT blc_account_role_account_permission_xref_pkey PRIMARY KEY (account_role_id, account_permission_id));
ALTER TABLE blc_resource_lock ADD CONSTRAINT uk7iegjt4gojv24q9bw8k0i4j0c UNIQUE (context_id, type_alias, sandbox_id, concept_key);
CREATE TABLE blc_export (id VARCHAR(36) NOT NULL, addl_parameters VARCHAR(10485760), application_id VARCHAR(36), author VARCHAR(255), created TIMESTAMP WITHOUT TIME ZONE, error_message VARCHAR(65535), exclusions VARCHAR(10485760), exporting_application_id VARCHAR(36), exporting_catalog_id VARCHAR(36), exporting_customer_context_id VARCHAR(36), exporting_sandbox_id VARCHAR(36), file_location VARCHAR(500), file_type VARCHAR(60), filter_string VARCHAR(65535), inclusions VARCHAR(10485760), last_updated TIMESTAMP WITHOUT TIME ZONE, name VARCHAR(255), number_of_records_to_process BIGINT, parent_id VARCHAR(36), status VARCHAR(60), target VARCHAR(60), tenant_id VARCHAR(36), time_zone_id VARCHAR(255), total_records_to_process BIGINT, CONSTRAINT blc_export_pkey PRIMARY KEY (id));
CREATE TABLE blc_export_lob (id VARCHAR(36) NOT NULL, content TEXT, path VARCHAR(500), CONSTRAINT blc_export_lob_pkey PRIMARY KEY (id));
ALTER TABLE blc_account_member ADD CONSTRAINT fk3e6k080umedbp5cwhv62fmv7h FOREIGN KEY (account_role_id) REFERENCES blc_account_role (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_account_member ADD CONSTRAINT fk3sskwvdot3n5un5vjxqtkymuw FOREIGN KEY (customer_id) REFERENCES blc_customer (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_account_address ADD CONSTRAINT fka4yqo28ciwwo698ivs0f5xse6 FOREIGN KEY (account_id) REFERENCES blc_account (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_account_member ADD CONSTRAINT fkb2cp0k5fsd8x4bvuh11mc582e FOREIGN KEY (account_id) REFERENCES blc_account (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_application_catalog ADD CONSTRAINT fkdaeorqo87oh0rdu1lfkpv3qow FOREIGN KEY (application_id) REFERENCES blc_application (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_account_role_account_permission_xref ADD CONSTRAINT fknrrfr5ufbo3bo33tplxlc3jk1 FOREIGN KEY (account_role_id) REFERENCES blc_account_role (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_segment_member ADD CONSTRAINT fkq6ll4w0sgrewpws1031ylaatx FOREIGN KEY (customer_id) REFERENCES blc_customer (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE blc_account_role_account_permission_xref ADD CONSTRAINT fktimu1r2ek1wy6nrvk25bs04l5 FOREIGN KEY (account_permission_id) REFERENCES blc_account_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
