-- liquibase formatted sql
-- changeset broadleaf:content-fields-migration-oracle
INSERT INTO "BLC_CONTENT_FIELD"
SELECT
substr(cf.id || cm.trk_catalog_context_id, 0, 36),
cf.allowed_models,
cf.attributes,
CASE WHEN cf.collection = 'true' THEN 'Y' ELSE 'N' END as collection,
cm.context_id as model_context_id,
substr(cf.id || cm.trk_catalog_context_id, 0, 36),
cf.display_order,
cf.help_text,
cf.hint,
cf.label,
cf.name,
cf.reference_type,
CASE WHEN cf.required = 'true' THEN 'Y' ELSE 'N' END as required,
cm.trk_archived,
CURRENT_TIMESTAMP,
cm.audit_creator,
cm.audit_update_time,
cm.audit_updater,
cm.trk_catalog_context_id,
cm.trk_catalog_level,
cm.trk_catalog_locale,
cm.trk_catalog_name,
cm.trk_parent_cat_context_id,
cm.trk_parent_cat_level,
cm.trk_parent_cat_locale,
cm.trk_parent_cat_name,
cm.trk_change_details,
cm.trk_composite_sort_level,
cm.trk_creating_application_id,
cm.trk_current_message,
cm.trk_field_overrides,
cm.trk_level,
cm.trk_max_field_versions,
cm.trk_sandbox_archived,
cm.trk_sub_container_catalog,
cm.trk_change_container_id,
cm.trk_change_container_name,
cm.trk_change_container_route_key,
cm.trk_sub_container_name,
cm.trk_sandbox_change_type,
cm.trk_sandbox_context_id,
cm.trk_sandbox_name,
cm.trk_sandbox_owner,
cm.trk_sandbox_stage,
cm.trk_tenant_id,
'N',
cf.type
FROM "BLC_CONTENT_MODEL" cm,
JSON_TABLE (cm.FIELDS, '$[*]'
COLUMNS "ID" VARCHAR2(36) PATH '$.id',
"ALLOWED_MODELS" CLOB PATH '$.allowedModels',
"ATTRIBUTES" CLOB PATH '$.attributes',
"COLLECTION" VARCHAR2(1 CHAR) PATH '$.collection',
"DISPLAY_ORDER" NUMBER(10,0) PATH '$.displayOrder',
"HELP_TEXT" VARCHAR2(255) PATH '$.helpText',
"HINT" VARCHAR2(255) PATH '$.hint',
"LABEL" VARCHAR2(255) PATH '$.label',
"NAME" VARCHAR2(255) PATH '$.name',
"REFERENCE_TYPE" VARCHAR2(60) PATH '$.referenceType',
"REQUIRED" VARCHAR2(1 CHAR) PATH '$.required',
"TRANSLATABLE" VARCHAR2(1 CHAR) PATH '$.translatable',
"TYPE" VARCHAR2(60) PATH '$.type'
) AS cf
WHERE NOT EXISTS (SELECT id FROM "BLC_CONTENT_FIELD" WHERE id = cf.id);