ALTER TABLE "public"."workflow_task" ADD CONSTRAINT "unique_workflow_task" UNIQUE (webasset, language_id);
ALTER TABLE "public"."users_cms_roles" ADD CONSTRAINT "users_cms_roles_parent1" UNIQUE (role_id, user_id);
ALTER TABLE "public"."tag" ADD CONSTRAINT "tag_tagname_host" UNIQUE (tagname, host_id);
ALTER TABLE "public"."structure" ADD CONSTRAINT "unique_struct_vel_var_name" UNIQUE (velocity_var_name);
ALTER TABLE "public"."report_parameter" ADD CONSTRAINT "report_parameter_report_inode_parameter_name_key" UNIQUE (report_inode, parameter_name);
ALTER TABLE "public"."relationship" ADD CONSTRAINT "relationship_relation_type_value_key" UNIQUE (relation_type_value);
ALTER TABLE "public"."publishing_environment" ADD CONSTRAINT "publishing_environment_name_key" UNIQUE (name);
ALTER TABLE "public"."publishing_end_point" ADD CONSTRAINT "publishing_end_point_server_name_key" UNIQUE (server_name);
ALTER TABLE "public"."portlet" ADD CONSTRAINT "portlet_role_key" UNIQUE (portletid);
ALTER TABLE "public"."permission_reference" ADD CONSTRAINT "permission_reference_asset_id_key" UNIQUE (asset_id);
ALTER TABLE "public"."permission" ADD CONSTRAINT "permission_permission_type_inode_id_roleid_key" UNIQUE (permission_type, inode_id, roleid);
ALTER TABLE "public"."layouts_cms_roles" ADD CONSTRAINT "layouts_cms_roles_parent1" UNIQUE (role_id, layout_id);
ALTER TABLE "public"."indicies" ADD CONSTRAINT "indicies_index_type_key" UNIQUE (index_type);
ALTER TABLE "public"."identifier" ADD CONSTRAINT "identifier_parent_path_asset_name_host_inode_key" UNIQUE (parent_path, asset_name, host_inode);
ALTER TABLE "public"."dist_journal" ADD CONSTRAINT "dist_journal_object_to_index_key" UNIQUE (object_to_index, serverid, journal_type);
ALTER TABLE "public"."cms_role" ADD CONSTRAINT "cms_role_name_role_key" UNIQUE (role_key);
ALTER TABLE "public"."cms_role" ADD CONSTRAINT "cms_role_name_db_fqn" UNIQUE (db_fqn);
ALTER TABLE "public"."cms_layouts_portlets" ADD CONSTRAINT "cms_layouts_portlets_parent1" UNIQUE (layout_id, portlet_id);
ALTER TABLE "public"."cms_layout" ADD CONSTRAINT "cms_layout_name_parent" UNIQUE (layout_name);
ALTER TABLE "public"."chain_link_code" ADD CONSTRAINT "chain_link_code_class_name_key" UNIQUE (class_name);
ALTER TABLE "public"."chain" ADD CONSTRAINT "chain_key_name_key" UNIQUE (key_name);
ALTER TABLE "public"."analytic_summary_period" ADD CONSTRAINT "analytic_summary_period_full_date_key" UNIQUE (full_date);
ALTER TABLE "public"."analytic_summary" ADD CONSTRAINT "analytic_summary_summary_period_id_host_id_key" UNIQUE (summary_period_id, host_id);
ALTER TABLE "public"."workflowtask_files" ADD CONSTRAINT "workflowtask_files_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_task" ADD CONSTRAINT "workflow_task_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_step" ADD CONSTRAINT "workflow_step_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_scheme_x_structure" ADD CONSTRAINT "workflow_scheme_x_structure_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_scheme" ADD CONSTRAINT "workflow_scheme_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_history" ADD CONSTRAINT "workflow_history_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_comment" ADD CONSTRAINT "workflow_comment_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_action_step" ADD CONSTRAINT "pk_workflow_action_step" PRIMARY KEY (action_id, step_id);
ALTER TABLE "public"."workflow_action_mappings" ADD CONSTRAINT "workflow_action_mappings_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_action_class_pars" ADD CONSTRAINT "workflow_action_class_pars_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_action_class" ADD CONSTRAINT "workflow_action_class_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."workflow_action" ADD CONSTRAINT "workflow_action_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."web_form" ADD CONSTRAINT "web_form_pkey" PRIMARY KEY (web_form_id);
ALTER TABLE "public"."usertrackerpath" ADD CONSTRAINT "usertrackerpath_pkey" PRIMARY KEY (usertrackerpathid);
ALTER TABLE "public"."usertracker" ADD CONSTRAINT "usertracker_pkey" PRIMARY KEY (usertrackerid);
ALTER TABLE "public"."users_to_delete" ADD CONSTRAINT "users_to_delete_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."users_cms_roles" ADD CONSTRAINT "users_cms_roles_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."user_preferences" ADD CONSTRAINT "user_preferences_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."user_filter" ADD CONSTRAINT "user_filter_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."user_comments" ADD CONSTRAINT "user_comments_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."user_" ADD CONSTRAINT "user__pkey" PRIMARY KEY (userid);
ALTER TABLE "public"."tree" ADD CONSTRAINT "tree_pkey" PRIMARY KEY (child, parent, relation_type);
ALTER TABLE "public"."trackback" ADD CONSTRAINT "trackback_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."template_version_info" ADD CONSTRAINT "template_version_info_pkey" PRIMARY KEY (identifier);
ALTER TABLE "public"."template_containers" ADD CONSTRAINT "template_containers_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."template" ADD CONSTRAINT "template_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."tag_inode" ADD CONSTRAINT "tag_inode_pkey" PRIMARY KEY (tag_id, inode);
ALTER TABLE "public"."tag" ADD CONSTRAINT "tag_pkey" PRIMARY KEY (tag_id);
ALTER TABLE "public"."system_event" ADD CONSTRAINT "pk_system_event" PRIMARY KEY (identifier);
ALTER TABLE "public"."structures_ir" ADD CONSTRAINT "structures_ir_pkey" PRIMARY KEY (local_inode, endpoint_id);
ALTER TABLE "public"."structure" ADD CONSTRAINT "structure_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."storage_x_data" ADD CONSTRAINT "storage_x_data_pkey" PRIMARY KEY (storage_hash, data_hash);
ALTER TABLE "public"."storage_group" ADD CONSTRAINT "storage_group_pkey" PRIMARY KEY (group_name);
ALTER TABLE "public"."storage_data" ADD CONSTRAINT "storage_data_pkey" PRIMARY KEY (hash_id);
ALTER TABLE "public"."storage" ADD CONSTRAINT "storage_pkey" PRIMARY KEY (path, group_name);
ALTER TABLE "public"."sitesearch_audit" ADD CONSTRAINT "sitesearch_audit_pkey" PRIMARY KEY (job_id, fire_date);
ALTER TABLE "public"."sitelic" ADD CONSTRAINT "sitelic_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."schemes_ir" ADD CONSTRAINT "schemes_ir_pkey" PRIMARY KEY (local_inode, endpoint_id);
ALTER TABLE "public"."rule_condition_value" ADD CONSTRAINT "rule_condition_value_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."rule_condition_group" ADD CONSTRAINT "rule_condition_group_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."rule_condition" ADD CONSTRAINT "rule_condition_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."rule_action_pars" ADD CONSTRAINT "rule_action_pars_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."rule_action" ADD CONSTRAINT "rule_action_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."report_parameter" ADD CONSTRAINT "report_parameter_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."report_asset" ADD CONSTRAINT "report_asset_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."release_" ADD CONSTRAINT "release__pkey" PRIMARY KEY (releaseid);
ALTER TABLE "public"."relationship" ADD CONSTRAINT "relationship_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."recipient" ADD CONSTRAINT "recipient_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."quartz_log" ADD CONSTRAINT "quartz_log_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."qrtz_triggers" ADD CONSTRAINT "qrtz_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_trigger_listeners" ADD CONSTRAINT "qrtz_trigger_listeners_pkey" PRIMARY KEY (trigger_name, trigger_group, trigger_listener);
ALTER TABLE "public"."qrtz_simple_triggers" ADD CONSTRAINT "qrtz_simple_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_scheduler_state" ADD CONSTRAINT "qrtz_scheduler_state_pkey" PRIMARY KEY (instance_name);
ALTER TABLE "public"."qrtz_paused_trigger_grps" ADD CONSTRAINT "qrtz_paused_trigger_grps_pkey" PRIMARY KEY (trigger_group);
ALTER TABLE "public"."qrtz_locks" ADD CONSTRAINT "qrtz_locks_pkey" PRIMARY KEY (lock_name);
ALTER TABLE "public"."qrtz_job_listeners" ADD CONSTRAINT "qrtz_job_listeners_pkey" PRIMARY KEY (job_name, job_group, job_listener);
ALTER TABLE "public"."qrtz_job_details" ADD CONSTRAINT "qrtz_job_details_pkey" PRIMARY KEY (job_name, job_group);
ALTER TABLE "public"."qrtz_fired_triggers" ADD CONSTRAINT "qrtz_fired_triggers_pkey" PRIMARY KEY (entry_id);
ALTER TABLE "public"."qrtz_excl_triggers" ADD CONSTRAINT "qrtz_excl_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_excl_trigger_listeners" ADD CONSTRAINT "qrtz_excl_trigger_listeners_pkey" PRIMARY KEY (trigger_name, trigger_group, trigger_listener);
ALTER TABLE "public"."qrtz_excl_simple_triggers" ADD CONSTRAINT "qrtz_excl_simple_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_excl_scheduler_state" ADD CONSTRAINT "qrtz_excl_scheduler_state_pkey" PRIMARY KEY (instance_name);
ALTER TABLE "public"."qrtz_excl_paused_trigger_grps" ADD CONSTRAINT "qrtz_excl_paused_trigger_grps_pkey" PRIMARY KEY (trigger_group);
ALTER TABLE "public"."qrtz_excl_locks" ADD CONSTRAINT "qrtz_excl_locks_pkey" PRIMARY KEY (lock_name);
ALTER TABLE "public"."qrtz_excl_job_listeners" ADD CONSTRAINT "qrtz_excl_job_listeners_pkey" PRIMARY KEY (job_name, job_group, job_listener);
ALTER TABLE "public"."qrtz_excl_job_details" ADD CONSTRAINT "qrtz_excl_job_details_pkey" PRIMARY KEY (job_name, job_group);
ALTER TABLE "public"."qrtz_excl_fired_triggers" ADD CONSTRAINT "qrtz_excl_fired_triggers_pkey" PRIMARY KEY (entry_id);
ALTER TABLE "public"."qrtz_excl_cron_triggers" ADD CONSTRAINT "qrtz_excl_cron_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_excl_calendars" ADD CONSTRAINT "qrtz_excl_calendars_pkey" PRIMARY KEY (calendar_name);
ALTER TABLE "public"."qrtz_excl_blob_triggers" ADD CONSTRAINT "qrtz_excl_blob_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_cron_triggers" ADD CONSTRAINT "qrtz_cron_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_calendars" ADD CONSTRAINT "qrtz_calendars_pkey" PRIMARY KEY (calendar_name);
ALTER TABLE "public"."qrtz_blob_triggers" ADD CONSTRAINT "qrtz_blob_triggers_pkey" PRIMARY KEY (trigger_name, trigger_group);
ALTER TABLE "public"."publishing_queue_audit" ADD CONSTRAINT "publishing_queue_audit_pkey" PRIMARY KEY (bundle_id);
ALTER TABLE "public"."publishing_queue" ADD CONSTRAINT "publishing_queue_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."publishing_environment" ADD CONSTRAINT "publishing_environment_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."publishing_end_point" ADD CONSTRAINT "publishing_end_point_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."publishing_bundle_environment" ADD CONSTRAINT "publishing_bundle_environment_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."publishing_bundle" ADD CONSTRAINT "publishing_bundle_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."portletpreferences" ADD CONSTRAINT "portletpreferences_pkey" PRIMARY KEY (portletid, userid, layoutid);
ALTER TABLE "public"."portlet" ADD CONSTRAINT "portlet_pkey" PRIMARY KEY (portletid, groupid, companyid);
ALTER TABLE "public"."pollsvote" ADD CONSTRAINT "pollsvote_pkey" PRIMARY KEY (questionid, userid);
ALTER TABLE "public"."pollsquestion" ADD CONSTRAINT "pollsquestion_pkey" PRIMARY KEY (questionid);
ALTER TABLE "public"."pollsdisplay" ADD CONSTRAINT "pollsdisplay_pkey" PRIMARY KEY (layoutid, userid, portletid);
ALTER TABLE "public"."pollschoice" ADD CONSTRAINT "pollschoice_pkey" PRIMARY KEY (choiceid, questionid);
ALTER TABLE "public"."plugin_property" ADD CONSTRAINT "plugin_property_pkey" PRIMARY KEY (plugin_id, propkey);
ALTER TABLE "public"."plugin" ADD CONSTRAINT "plugin_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."permission_reference" ADD CONSTRAINT "permission_reference_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."permission" ADD CONSTRAINT "permission_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."passwordtracker" ADD CONSTRAINT "passwordtracker_pkey" PRIMARY KEY (passwordtrackerid);
ALTER TABLE "public"."notification" ADD CONSTRAINT "pk_notification" PRIMARY KEY (group_id, user_id);
ALTER TABLE "public"."multi_tree" ADD CONSTRAINT "multi_tree_pkey" PRIMARY KEY (child, parent1, parent2, relation_type, personalization);
ALTER TABLE "public"."mailing_list" ADD CONSTRAINT "mailing_list_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."log_mapper" ADD CONSTRAINT "log_mapper_pkey" PRIMARY KEY (log_name);
ALTER TABLE "public"."links" ADD CONSTRAINT "links_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."link_version_info" ADD CONSTRAINT "link_version_info_pkey" PRIMARY KEY (identifier);
ALTER TABLE "public"."layouts_cms_roles" ADD CONSTRAINT "layouts_cms_roles_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."language" ADD CONSTRAINT "language_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."inode" ADD CONSTRAINT "inode_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."indicies" ADD CONSTRAINT "indicies_pkey" PRIMARY KEY (index_name);
ALTER TABLE "public"."import_audit" ADD CONSTRAINT "import_audit_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."image" ADD CONSTRAINT "image_pkey" PRIMARY KEY (imageid);
ALTER TABLE "public"."identifier" ADD CONSTRAINT "identifier_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."htmlpages_ir" ADD CONSTRAINT "htmlpages_ir_pkey" PRIMARY KEY (local_working_inode, language_id, endpoint_id);
ALTER TABLE "public"."host_variable" ADD CONSTRAINT "host_variable_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."folders_ir" ADD CONSTRAINT "folders_ir_pkey" PRIMARY KEY (local_inode, endpoint_id);
ALTER TABLE "public"."folder" ADD CONSTRAINT "folder_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."fixes_audit" ADD CONSTRAINT "fixes_audit_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."fileassets_ir" ADD CONSTRAINT "fileassets_ir_pkey" PRIMARY KEY (local_working_inode, language_id, endpoint_id);
ALTER TABLE "public"."field_variable" ADD CONSTRAINT "field_variable_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."field" ADD CONSTRAINT "field_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."dot_rule" ADD CONSTRAINT "dot_rule_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."dot_containers" ADD CONSTRAINT "dot_containers_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."dot_cluster" ADD CONSTRAINT "dot_cluster_pkey" PRIMARY KEY (cluster_id);
ALTER TABLE "public"."dist_reindex_journal" ADD CONSTRAINT "dist_reindex_journal_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."dist_process" ADD CONSTRAINT "dist_process_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."dist_journal" ADD CONSTRAINT "dist_journal_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."db_version" ADD CONSTRAINT "db_version_pkey" PRIMARY KEY (db_version);
ALTER TABLE "public"."dashboard_user_preferences" ADD CONSTRAINT "dashboard_user_preferences_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."counter" ADD CONSTRAINT "counter_pkey" PRIMARY KEY (name);
ALTER TABLE "public"."contentlet_version_info" ADD CONSTRAINT "contentlet_version_info_pkey" PRIMARY KEY (identifier, lang);
ALTER TABLE "public"."contentlet" ADD CONSTRAINT "contentlet_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."content_rating" ADD CONSTRAINT "content_rating_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."container_version_info" ADD CONSTRAINT "container_version_info_pkey" PRIMARY KEY (identifier);
ALTER TABLE "public"."container_structures" ADD CONSTRAINT "container_structures_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."company" ADD CONSTRAINT "company_pkey" PRIMARY KEY (companyid);
ALTER TABLE "public"."communication" ADD CONSTRAINT "communication_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."cms_roles_ir" ADD CONSTRAINT "cms_roles_ir_pkey" PRIMARY KEY (local_role_id, endpoint_id);
ALTER TABLE "public"."cms_role" ADD CONSTRAINT "cms_role_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."cms_layouts_portlets" ADD CONSTRAINT "cms_layouts_portlets_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."cms_layout" ADD CONSTRAINT "cms_layout_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."cluster_server_uptime" ADD CONSTRAINT "cluster_server_uptime_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."cluster_server_action" ADD CONSTRAINT "cluster_server_action_pkey" PRIMARY KEY (server_action_id);
ALTER TABLE "public"."cluster_server" ADD CONSTRAINT "cluster_server_pkey" PRIMARY KEY (server_id);
ALTER TABLE "public"."clickstream_request" ADD CONSTRAINT "clickstream_request_pkey" PRIMARY KEY (clickstream_request_id);
ALTER TABLE "public"."clickstream_404" ADD CONSTRAINT "clickstream_404_pkey" PRIMARY KEY (clickstream_404_id);
ALTER TABLE "public"."clickstream" ADD CONSTRAINT "clickstream_pkey" PRIMARY KEY (clickstream_id);
ALTER TABLE "public"."click" ADD CONSTRAINT "click_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."challenge_question" ADD CONSTRAINT "challenge_question_pkey" PRIMARY KEY (cquestionid);
ALTER TABLE "public"."chain_state_parameter" ADD CONSTRAINT "chain_state_parameter_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."chain_state" ADD CONSTRAINT "chain_state_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."chain_link_code" ADD CONSTRAINT "chain_link_code_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."chain" ADD CONSTRAINT "chain_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."category" ADD CONSTRAINT "category_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."campaign" ADD CONSTRAINT "campaign_pkey" PRIMARY KEY (inode);
ALTER TABLE "public"."calendar_reminder" ADD CONSTRAINT "calendar_reminder_pkey" PRIMARY KEY (user_id, event_id, send_date);
ALTER TABLE "public"."broken_link" ADD CONSTRAINT "broken_link_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."api_token_issued" ADD CONSTRAINT "api_token_issued_pkey" PRIMARY KEY (token_id);
ALTER TABLE "public"."analytic_summary_workstream" ADD CONSTRAINT "analytic_summary_workstream_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary_visits" ADD CONSTRAINT "analytic_summary_visits_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary_referer" ADD CONSTRAINT "analytic_summary_referer_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary_period" ADD CONSTRAINT "analytic_summary_period_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary_pages" ADD CONSTRAINT "analytic_summary_pages_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary_content" ADD CONSTRAINT "analytic_summary_content_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary_404" ADD CONSTRAINT "analytic_summary_404_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."analytic_summary" ADD CONSTRAINT "analytic_summary_pkey" PRIMARY KEY (id);
ALTER TABLE "public"."adminconfig" ADD CONSTRAINT "adminconfig_pkey" PRIMARY KEY (configid);
ALTER TABLE "public"."address" ADD CONSTRAINT "address_pkey" PRIMARY KEY (addressid);
ALTER TABLE "public"."workflowtask_files" ADD CONSTRAINT "fk_workflow_id" FOREIGN KEY (workflowtask_id) REFERENCES workflow_task(id);
ALTER TABLE "public"."workflow_task" ADD CONSTRAINT "fk_workflow_task_language" FOREIGN KEY (language_id) REFERENCES language(id);
ALTER TABLE "public"."workflow_task" ADD CONSTRAINT "fk_workflow_step" FOREIGN KEY (status) REFERENCES workflow_step(id);
ALTER TABLE "public"."workflow_task" ADD CONSTRAINT "fk_workflow_assign" FOREIGN KEY (assigned_to) REFERENCES cms_role(id);
ALTER TABLE "public"."workflow_step" ADD CONSTRAINT "workflow_step_scheme_id_fkey" FOREIGN KEY (scheme_id) REFERENCES workflow_scheme(id);
ALTER TABLE "public"."workflow_step" ADD CONSTRAINT "fk_escalation_action" FOREIGN KEY (escalation_action) REFERENCES workflow_action(id);
ALTER TABLE "public"."workflow_scheme_x_structure" ADD CONSTRAINT "workflow_scheme_x_structure_structure_id_fkey" FOREIGN KEY (structure_id) REFERENCES structure(inode);
ALTER TABLE "public"."workflow_scheme_x_structure" ADD CONSTRAINT "workflow_scheme_x_structure_scheme_id_fkey" FOREIGN KEY (scheme_id) REFERENCES workflow_scheme(id);
ALTER TABLE "public"."workflow_history" ADD CONSTRAINT "workflowtask_id_history_fk" FOREIGN KEY (workflowtask_id) REFERENCES workflow_task(id);
ALTER TABLE "public"."workflow_comment" ADD CONSTRAINT "workflowtask_id_comment_fk" FOREIGN KEY (workflowtask_id) REFERENCES workflow_task(id);
ALTER TABLE "public"."workflow_action_step" ADD CONSTRAINT "fk_w_action_step_step_id" FOREIGN KEY (step_id) REFERENCES workflow_step(id);
ALTER TABLE "public"."workflow_action_step" ADD CONSTRAINT "fk_w_action_step_action_id" FOREIGN KEY (action_id) REFERENCES workflow_action(id);
ALTER TABLE "public"."workflow_action_class_pars" ADD CONSTRAINT "workflow_action_class_pars_workflow_action_class_id_fkey" FOREIGN KEY (workflow_action_class_id) REFERENCES workflow_action_class(id);
ALTER TABLE "public"."workflow_action_class" ADD CONSTRAINT "workflow_action_class_action_id_fkey" FOREIGN KEY (action_id) REFERENCES workflow_action(id);
ALTER TABLE "public"."workflow_action" ADD CONSTRAINT "workflow_action_next_assign_fkey" FOREIGN KEY (next_assign) REFERENCES cms_role(id);
ALTER TABLE "public"."users_cms_roles" ADD CONSTRAINT "fkusers_cms_roles2" FOREIGN KEY (user_id) REFERENCES user_(userid);
ALTER TABLE "public"."users_cms_roles" ADD CONSTRAINT "fkusers_cms_roles1" FOREIGN KEY (role_id) REFERENCES cms_role(id);
ALTER TABLE "public"."user_filter" ADD CONSTRAINT "fke042126c5fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."user_comments" ADD CONSTRAINT "fkdf1b37e85fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."template_version_info" ADD CONSTRAINT "fk_template_version_info_working" FOREIGN KEY (working_inode) REFERENCES template(inode);
ALTER TABLE "public"."template_version_info" ADD CONSTRAINT "fk_template_version_info_live" FOREIGN KEY (live_inode) REFERENCES template(inode);
ALTER TABLE "public"."template_version_info" ADD CONSTRAINT "fk_template_version_info_identifier" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."template_version_info" ADD CONSTRAINT "fk_temp_ver_info_lockedby" FOREIGN KEY (locked_by) REFERENCES user_(userid);
ALTER TABLE "public"."template_containers" ADD CONSTRAINT "fk_template_id" FOREIGN KEY (template_id) REFERENCES identifier(id);
ALTER TABLE "public"."template_containers" ADD CONSTRAINT "fk_container_id" FOREIGN KEY (container_id) REFERENCES identifier(id);
ALTER TABLE "public"."template" ADD CONSTRAINT "template_identifier_fk" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."template" ADD CONSTRAINT "fkb13acc7a5fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."template" ADD CONSTRAINT "fk_user_template" FOREIGN KEY (mod_user) REFERENCES user_(userid);
ALTER TABLE "public"."tag_inode" ADD CONSTRAINT "fk_tag_inode_tagid" FOREIGN KEY (tag_id) REFERENCES tag(tag_id);
ALTER TABLE "public"."structure" ADD CONSTRAINT "fk_structure_host" FOREIGN KEY (host) REFERENCES identifier(id);
ALTER TABLE "public"."structure" ADD CONSTRAINT "fk_structure_folder" FOREIGN KEY (folder) REFERENCES folder(inode);
ALTER TABLE "public"."structure" ADD CONSTRAINT "fk89d2d735fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."storage_x_data" ADD CONSTRAINT "storage_x_data_data_hash_fkey" FOREIGN KEY (data_hash) REFERENCES storage_data(hash_id);
ALTER TABLE "public"."storage" ADD CONSTRAINT "storage_group_name_fkey" FOREIGN KEY (group_name) REFERENCES storage_group(group_name);
ALTER TABLE "public"."rule_condition_value" ADD CONSTRAINT "rule_condition_value_condition_id_fkey" FOREIGN KEY (condition_id) REFERENCES rule_condition(id);
ALTER TABLE "public"."rule_condition_group" ADD CONSTRAINT "rule_condition_group_rule_id_fkey" FOREIGN KEY (rule_id) REFERENCES dot_rule(id);
ALTER TABLE "public"."rule_condition" ADD CONSTRAINT "rule_condition_condition_group_fkey" FOREIGN KEY (condition_group) REFERENCES rule_condition_group(id);
ALTER TABLE "public"."rule_action_pars" ADD CONSTRAINT "rule_action_pars_rule_action_id_fkey" FOREIGN KEY (rule_action_id) REFERENCES rule_action(id);
ALTER TABLE "public"."rule_action" ADD CONSTRAINT "rule_action_rule_id_fkey" FOREIGN KEY (rule_id) REFERENCES dot_rule(id);
ALTER TABLE "public"."report_parameter" ADD CONSTRAINT "fk22da125e5fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."report_asset" ADD CONSTRAINT "fk3765ec255fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."relationship" ADD CONSTRAINT "fkf06476385fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."recipient" ADD CONSTRAINT "fk30e172195fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."qrtz_triggers" ADD CONSTRAINT "qrtz_triggers_job_name_job_group_fkey" FOREIGN KEY (job_name, job_group) REFERENCES qrtz_job_details(job_name, job_group);
ALTER TABLE "public"."qrtz_trigger_listeners" ADD CONSTRAINT "qrtz_trigger_listeners_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_simple_triggers" ADD CONSTRAINT "qrtz_simple_triggers_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_job_listeners" ADD CONSTRAINT "qrtz_job_listeners_job_name_job_group_fkey" FOREIGN KEY (job_name, job_group) REFERENCES qrtz_job_details(job_name, job_group);
ALTER TABLE "public"."qrtz_excl_triggers" ADD CONSTRAINT "qrtz_excl_triggers_job_name_job_group_fkey" FOREIGN KEY (job_name, job_group) REFERENCES qrtz_excl_job_details(job_name, job_group);
ALTER TABLE "public"."qrtz_excl_trigger_listeners" ADD CONSTRAINT "qrtz_excl_trigger_listeners_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_excl_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_excl_simple_triggers" ADD CONSTRAINT "qrtz_excl_simple_triggers_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_excl_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_excl_job_listeners" ADD CONSTRAINT "qrtz_excl_job_listeners_job_name_job_group_fkey" FOREIGN KEY (job_name, job_group) REFERENCES qrtz_excl_job_details(job_name, job_group);
ALTER TABLE "public"."qrtz_excl_cron_triggers" ADD CONSTRAINT "qrtz_excl_cron_triggers_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_excl_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_excl_blob_triggers" ADD CONSTRAINT "qrtz_excl_blob_triggers_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_excl_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_cron_triggers" ADD CONSTRAINT "qrtz_cron_triggers_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."qrtz_blob_triggers" ADD CONSTRAINT "qrtz_blob_triggers_trigger_name_trigger_group_fkey" FOREIGN KEY (trigger_name, trigger_group) REFERENCES qrtz_triggers(trigger_name, trigger_group);
ALTER TABLE "public"."publishing_bundle_environment" ADD CONSTRAINT "fk_environment_id" FOREIGN KEY (environment_id) REFERENCES publishing_environment(id);
ALTER TABLE "public"."publishing_bundle_environment" ADD CONSTRAINT "fk_bundle_id" FOREIGN KEY (bundle_id) REFERENCES publishing_bundle(id);
ALTER TABLE "public"."publishing_bundle" ADD CONSTRAINT "fk_publishing_bundle_owner" FOREIGN KEY (owner) REFERENCES user_(userid);
ALTER TABLE "public"."plugin_property" ADD CONSTRAINT "fk_plugin_plugin_property" FOREIGN KEY (plugin_id) REFERENCES plugin(id);
ALTER TABLE "public"."permission" ADD CONSTRAINT "permission_role_fk" FOREIGN KEY (roleid) REFERENCES cms_role(id);
ALTER TABLE "public"."mailing_list" ADD CONSTRAINT "fk7bc2cd925fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."links" ADD CONSTRAINT "links_identifier_fk" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."links" ADD CONSTRAINT "fk_user_links" FOREIGN KEY (mod_user) REFERENCES user_(userid);
ALTER TABLE "public"."links" ADD CONSTRAINT "fk6234fb95fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."link_version_info" ADD CONSTRAINT "fk_link_version_info_working" FOREIGN KEY (working_inode) REFERENCES links(inode);
ALTER TABLE "public"."link_version_info" ADD CONSTRAINT "fk_link_version_info_live" FOREIGN KEY (live_inode) REFERENCES links(inode);
ALTER TABLE "public"."link_version_info" ADD CONSTRAINT "fk_link_version_info_identifier" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."link_version_info" ADD CONSTRAINT "fk_link_ver_info_lockedby" FOREIGN KEY (locked_by) REFERENCES user_(userid);
ALTER TABLE "public"."layouts_cms_roles" ADD CONSTRAINT "fklayouts_cms_roles2" FOREIGN KEY (layout_id) REFERENCES cms_layout(id);
ALTER TABLE "public"."layouts_cms_roles" ADD CONSTRAINT "fklayouts_cms_roles1" FOREIGN KEY (role_id) REFERENCES cms_role(id);
ALTER TABLE "public"."folder" ADD CONSTRAINT "folder_identifier_fk" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."folder" ADD CONSTRAINT "fkb45d1c6e5fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."folder" ADD CONSTRAINT "fk_folder_file_structure_type" FOREIGN KEY (default_file_type) REFERENCES structure(inode);
ALTER TABLE "public"."field" ADD CONSTRAINT "fk5cea0fa5fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."dot_containers" ADD CONSTRAINT "fk_user_containers" FOREIGN KEY (mod_user) REFERENCES user_(userid);
ALTER TABLE "public"."dot_containers" ADD CONSTRAINT "fk8a844125fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."dot_containers" ADD CONSTRAINT "containers_identifier_fk" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."dashboard_user_preferences" ADD CONSTRAINT "fk496242cfd12c0c3b" FOREIGN KEY (summary_404_id) REFERENCES analytic_summary_404(id);
ALTER TABLE "public"."contentlet_version_info" ADD CONSTRAINT "fk_contentlet_version_info_working" FOREIGN KEY (working_inode) REFERENCES contentlet(inode);
ALTER TABLE "public"."contentlet_version_info" ADD CONSTRAINT "fk_contentlet_version_info_live" FOREIGN KEY (live_inode) REFERENCES contentlet(inode);
ALTER TABLE "public"."contentlet_version_info" ADD CONSTRAINT "fk_contentlet_version_info_lang" FOREIGN KEY (lang) REFERENCES language(id);
ALTER TABLE "public"."contentlet_version_info" ADD CONSTRAINT "fk_contentlet_version_info_identifier" FOREIGN KEY (identifier) REFERENCES identifier(id) ON DELETE CASCADE;
ALTER TABLE "public"."contentlet_version_info" ADD CONSTRAINT "fk_con_ver_lockedby" FOREIGN KEY (locked_by) REFERENCES user_(userid);
ALTER TABLE "public"."contentlet" ADD CONSTRAINT "fkfc4ef025fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."contentlet" ADD CONSTRAINT "fk_user_contentlet" FOREIGN KEY (mod_user) REFERENCES user_(userid);
ALTER TABLE "public"."contentlet" ADD CONSTRAINT "fk_structure_inode" FOREIGN KEY (structure_inode) REFERENCES structure(inode);
ALTER TABLE "public"."contentlet" ADD CONSTRAINT "fk_contentlet_lang" FOREIGN KEY (language_id) REFERENCES language(id);
ALTER TABLE "public"."contentlet" ADD CONSTRAINT "content_identifier_fk" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."container_version_info" ADD CONSTRAINT "fk_tainer_ver_info_lockedby" FOREIGN KEY (locked_by) REFERENCES user_(userid);
ALTER TABLE "public"."container_version_info" ADD CONSTRAINT "fk_container_version_info_working" FOREIGN KEY (working_inode) REFERENCES dot_containers(inode);
ALTER TABLE "public"."container_version_info" ADD CONSTRAINT "fk_container_version_info_live" FOREIGN KEY (live_inode) REFERENCES dot_containers(inode);
ALTER TABLE "public"."container_version_info" ADD CONSTRAINT "fk_container_version_info_identifier" FOREIGN KEY (identifier) REFERENCES identifier(id);
ALTER TABLE "public"."container_structures" ADD CONSTRAINT "fk_cs_inode" FOREIGN KEY (container_inode) REFERENCES inode(inode);
ALTER TABLE "public"."container_structures" ADD CONSTRAINT "fk_cs_container_id" FOREIGN KEY (container_id) REFERENCES identifier(id);
ALTER TABLE "public"."communication" ADD CONSTRAINT "fkc24acfd65fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."cms_role" ADD CONSTRAINT "fkcms_role_parent" FOREIGN KEY (parent) REFERENCES cms_role(id);
ALTER TABLE "public"."cms_layouts_portlets" ADD CONSTRAINT "fkcms_layouts_portlets" FOREIGN KEY (layout_id) REFERENCES cms_layout(id);
ALTER TABLE "public"."cluster_server_uptime" ADD CONSTRAINT "fk_cluster_server_id" FOREIGN KEY (server_id) REFERENCES cluster_server(server_id);
ALTER TABLE "public"."cluster_server_uptime" ADD CONSTRAINT "cluster_server_uptime_server_id_fkey" FOREIGN KEY (server_id) REFERENCES cluster_server(server_id);
ALTER TABLE "public"."cluster_server" ADD CONSTRAINT "fk_cluster_id" FOREIGN KEY (cluster_id) REFERENCES dot_cluster(cluster_id);
ALTER TABLE "public"."click" ADD CONSTRAINT "fk5a5c5885fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."chain_state_parameter" ADD CONSTRAINT "fk_parameter_state" FOREIGN KEY (chain_state_id) REFERENCES chain_state(id);
ALTER TABLE "public"."chain_state" ADD CONSTRAINT "fk_state_code" FOREIGN KEY (link_code_id) REFERENCES chain_link_code(id);
ALTER TABLE "public"."chain_state" ADD CONSTRAINT "fk_state_chain" FOREIGN KEY (chain_id) REFERENCES chain(id);
ALTER TABLE "public"."category" ADD CONSTRAINT "fk302bcfe5fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."campaign" ADD CONSTRAINT "fkf7a901105fb51eb" FOREIGN KEY (inode) REFERENCES inode(inode);
ALTER TABLE "public"."broken_link" ADD CONSTRAINT "fk_brokenl_field" FOREIGN KEY (field) REFERENCES field(inode) ON DELETE CASCADE;
ALTER TABLE "public"."broken_link" ADD CONSTRAINT "fk_brokenl_content" FOREIGN KEY (inode) REFERENCES contentlet(inode) ON DELETE CASCADE;
ALTER TABLE "public"."analytic_summary_visits" ADD CONSTRAINT "fk9eac9733b7b46300" FOREIGN KEY (summary_period_id) REFERENCES analytic_summary_period(id);
ALTER TABLE "public"."analytic_summary_referer" ADD CONSTRAINT "fk5bc0f3e2ed30e054" FOREIGN KEY (summary_id) REFERENCES analytic_summary(id);
ALTER TABLE "public"."analytic_summary_pages" ADD CONSTRAINT "fka1ad33b9ed30e054" FOREIGN KEY (summary_id) REFERENCES analytic_summary(id);
ALTER TABLE "public"."analytic_summary_content" ADD CONSTRAINT "fk53cb4f2eed30e054" FOREIGN KEY (summary_id) REFERENCES analytic_summary(id);
ALTER TABLE "public"."analytic_summary_404" ADD CONSTRAINT "fk7050866db7b46300" FOREIGN KEY (summary_period_id) REFERENCES analytic_summary_period(id);
ALTER TABLE "public"."analytic_summary" ADD CONSTRAINT "fk9e1a7f4b7b46300" FOREIGN KEY (summary_period_id) REFERENCES analytic_summary_period(id);
CREATE OR REPLACE FUNCTION identifier_parent_path_check() RETURNS trigger AS '
 DECLARE
    folderId varchar(100);
  BEGIN
     IF (tg_op = ''INSERT'' OR tg_op = ''UPDATE'') THEN
      IF(NEW.parent_path=''/'') OR (NEW.parent_path=''/System folder'') THEN
        RETURN NEW;
     ELSE
      select id into folderId from identifier where asset_type=''folder'' and host_inode = NEW.host_inode and parent_path||asset_name||''/'' = NEW.parent_path and id <> NEW.id;
      IF FOUND THEN
        RETURN NEW;
      ELSE
        RAISE EXCEPTION ''Cannot % folder % [%] in path % as one or more parent folders do not exist in Site %'', tg_op, NEW.asset_name, NEW.id, NEW.parent_path, NEW.host_inode;
        RETURN NULL;
      END IF;
     END IF;
    END IF;
RETURN NULL;
END
  ' LANGUAGE plpgsql;
CREATE TRIGGER identifier_parent_path_trigger
  BEFORE INSERT OR UPDATE
  ON identifier FOR EACH ROW
  EXECUTE PROCEDURE identifier_parent_path_check();