in src/dispatch/database/revisions/tenant/versions/2021-06-15_8a558baeef05.py [0:0]
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "workflow_term", type_="foreignkey")
op.drop_constraint(None, "workflow_term", type_="foreignkey")
op.create_foreign_key(
"workflow_term_term_id_fkey",
"workflow_term",
"term",
["term_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"workflow_term_workflow_id_fkey",
"workflow_term",
"workflow",
["workflow_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "workflow_instance_artifact", type_="foreignkey")
op.drop_constraint(None, "workflow_instance_artifact", type_="foreignkey")
op.create_foreign_key(
"workflow_instance_artifact_workflow_instance_id_fkey",
"workflow_instance_artifact",
"workflow_instance",
["workflow_instance_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"workflow_instance_artifact_document_id_fkey",
"workflow_instance_artifact",
"document",
["document_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "workflow_instance", type_="foreignkey")
op.drop_constraint(None, "workflow_instance", type_="foreignkey")
op.drop_constraint(None, "workflow_instance", type_="foreignkey")
op.create_foreign_key(
"workflow_instance_workflow_id_fkey",
"workflow_instance",
"workflow",
["workflow_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"workflow_instance_incident_id_fkey",
"workflow_instance",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"workflow_instance_creator_id_fkey",
"workflow_instance",
"participant",
["creator_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "workflow_incident_type", type_="foreignkey")
op.drop_constraint(None, "workflow_incident_type", type_="foreignkey")
op.create_foreign_key(
"workflow_incident_type_workflow_id_fkey",
"workflow_incident_type",
"workflow",
["workflow_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"workflow_incident_type_incident_type_id_fkey",
"workflow_incident_type",
"incident_type",
["incident_type_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "workflow_incident_priority", type_="foreignkey")
op.drop_constraint(None, "workflow_incident_priority", type_="foreignkey")
op.create_foreign_key(
"workflow_incident_priority_workflow_id_fkey",
"workflow_incident_priority",
"workflow",
["workflow_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"workflow_incident_priority_incident_priority_id_fkey",
"workflow_incident_priority",
"incident_priority",
["incident_priority_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "workflow", type_="foreignkey")
op.drop_constraint(None, "workflow", type_="foreignkey")
op.create_foreign_key(
"workflow_project_id_fkey",
"workflow",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"workflow_plugin_id_fkey",
"workflow",
"plugin",
["plugin_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "ticket", type_="foreignkey")
op.create_foreign_key(
"ticket_incident_id_fkey",
"ticket",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "term", type_="foreignkey")
op.create_foreign_key(
"term_project_id_fkey",
"term",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "team_contact_incident", type_="foreignkey")
op.drop_constraint(None, "team_contact_incident", type_="foreignkey")
op.create_foreign_key(
"team_contact_incident_team_contact_id_fkey",
"team_contact_incident",
"team_contact",
["team_contact_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"team_contact_incident_incident_id_fkey",
"team_contact_incident",
"incident",
["incident_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "team_contact", type_="foreignkey")
op.create_foreign_key(
"team_contact_project_id_fkey",
"team_contact",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "task_tickets", type_="foreignkey")
op.drop_constraint(None, "task_tickets", type_="foreignkey")
op.create_foreign_key(
"task_tickets_ticket_id_fkey",
"task_tickets",
"ticket",
["ticket_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"task_tickets_task_id_fkey",
"task_tickets",
"task",
["task_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "task_assignees", type_="foreignkey")
op.drop_constraint(None, "task_assignees", type_="foreignkey")
op.create_foreign_key(
"task_assignees_participant_id_fkey",
"task_assignees",
"participant",
["participant_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"task_assignees_task_id_fkey",
"task_assignees",
"task",
["task_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "task", type_="foreignkey")
op.drop_constraint(None, "task", type_="foreignkey")
op.drop_constraint(None, "task", type_="foreignkey")
op.create_foreign_key(
"task_owner_id_fkey",
"task",
"participant",
["owner_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"task_creator_id_fkey",
"task",
"participant",
["creator_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"task_incident_id_fkey",
"task",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "tag_type", type_="foreignkey")
op.create_foreign_key(
"tag_type_project_id_fkey",
"tag_type",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "tag", type_="foreignkey")
op.drop_constraint(None, "tag", type_="foreignkey")
op.create_foreign_key(
"tag_tag_type_id_fkey", "tag", "tag_type", ["tag_type_id"], ["id"], referent_schema="public"
)
op.create_foreign_key(
"tag_project_id_fkey",
"tag",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "storage", type_="foreignkey")
op.create_foreign_key(
"storage_incident_id_fkey",
"storage",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "service_incident", type_="foreignkey")
op.drop_constraint(None, "service_incident", type_="foreignkey")
op.create_foreign_key(
"service_incident_incident_id_fkey",
"service_incident",
"incident",
["incident_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"service_incident_service_id_fkey",
"service_incident",
"service",
["service_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "service", type_="foreignkey")
op.create_foreign_key(
"service_project_id_fkey",
"service",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "search_filter", type_="foreignkey")
op.drop_constraint(None, "search_filter", type_="foreignkey")
op.create_foreign_key(
"search_filter_creator_id_fkey",
"search_filter",
"dispatch_user",
["creator_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"search_filter_project_id_fkey",
"search_filter",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "report", type_="foreignkey")
op.drop_constraint(None, "report", type_="foreignkey")
op.create_foreign_key(
"report_incident_id_fkey",
"report",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"report_participant_id_fkey",
"report",
"participant",
["participant_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "recommendation_match", type_="foreignkey")
op.create_foreign_key(
"recommendation_match_recommendation_id_fkey",
"recommendation_match",
"recommendation",
["recommendation_id"],
["id"],
referent_schema="public",
)
op.add_column(
"recommendation", sa.Column("text", sa.VARCHAR(), autoincrement=False, nullable=True)
)
op.drop_constraint(None, "recommendation", type_="foreignkey")
op.create_foreign_key(
"recommendation_incident_id_fkey",
"recommendation",
"incident",
["incident_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "project", type_="foreignkey")
op.create_foreign_key(
"project_organization_id_fkey",
"project",
"organization",
["organization_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "plugin_instance", type_="foreignkey")
op.drop_constraint(None, "plugin_instance", type_="foreignkey")
op.create_foreign_key(
"plugin_instance_project_id_fkey",
"plugin_instance",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"plugin_instance_plugin_id_fkey",
"plugin_instance",
"plugin",
["plugin_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "participant_role", type_="foreignkey")
op.create_foreign_key(
"participant_role_participant_id_fkey",
"participant_role",
"participant",
["participant_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "participant", type_="foreignkey")
op.drop_constraint(None, "participant", type_="foreignkey")
op.drop_constraint(None, "participant", type_="foreignkey")
op.drop_constraint(None, "participant", type_="foreignkey")
op.create_foreign_key(
"participant_individual_contact_id_fkey",
"participant",
"individual_contact",
["individual_contact_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"participant_added_by_id_fkey",
"participant",
"participant",
["added_by_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"participant_incident_id_fkey",
"participant",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"participant_service_id_fkey",
"participant",
"service",
["service_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "notification", type_="foreignkey")
op.create_foreign_key(
"notification_project_id_fkey",
"notification",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "individual_contact", type_="foreignkey")
op.drop_constraint(None, "individual_contact", type_="foreignkey")
op.create_foreign_key(
"individual_contact_team_contact_id_fkey",
"individual_contact",
"team_contact",
["team_contact_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"individual_contact_project_id_fkey",
"individual_contact",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "incident_type", type_="foreignkey")
op.drop_constraint(None, "incident_type", type_="foreignkey")
op.drop_constraint(None, "incident_type", type_="foreignkey")
op.drop_constraint(None, "incident_type", type_="foreignkey")
op.create_foreign_key(
"incident_type_liason_service_id_fkey",
"incident_type",
"service",
["liaison_service_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"incident_type_commander_service_id_fkey",
"incident_type",
"service",
["commander_service_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"incident_type_project_id_fkey",
"incident_type",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"incident_type_template_document_id_fkey",
"incident_type",
"document",
["template_document_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "incident_priority", type_="foreignkey")
op.create_foreign_key(
"incident_priority_project_id_fkey",
"incident_priority",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "incident_cost_type", type_="foreignkey")
op.create_foreign_key(
"incident_cost_type_project_id_fkey",
"incident_cost_type",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "incident_cost", type_="foreignkey")
op.drop_constraint(None, "incident_cost", type_="foreignkey")
op.drop_constraint(None, "incident_cost", type_="foreignkey")
op.create_foreign_key(
"incident_cost_incident_cost_type_id_fkey",
"incident_cost",
"incident_cost_type",
["incident_cost_type_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"incident_cost_project_id_fkey",
"incident_cost",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"incident_cost_incident_id_fkey",
"incident_cost",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "incident", type_="foreignkey")
op.drop_constraint(None, "incident", type_="foreignkey")
op.drop_constraint(None, "incident", type_="foreignkey")
op.drop_constraint(None, "incident", type_="foreignkey")
op.create_foreign_key(
"incident_incident_priority_id_fkey",
"incident",
"incident_priority",
["incident_priority_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"incident_duplicate_id_fkey",
"incident",
"incident",
["duplicate_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"incident_incident_type_id_fkey",
"incident",
"incident_type",
["incident_type_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"incident_project_id_fkey",
"incident",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "group", type_="foreignkey")
op.create_foreign_key(
"group_incident_id_fkey",
"group",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "feedback", type_="foreignkey")
op.drop_constraint(None, "feedback", type_="foreignkey")
op.create_foreign_key(
"feedback_participant_id_fkey",
"feedback",
"participant",
["participant_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"feedback_incident_id_fkey",
"feedback",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "event", type_="foreignkey")
op.drop_constraint(None, "event", type_="foreignkey")
op.create_foreign_key(
"event_individual_id_fkey",
"event",
"individual_contact",
["individual_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"event_incident_id_fkey",
"event",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "document", type_="foreignkey")
op.drop_constraint(None, "document", type_="foreignkey")
op.drop_constraint(None, "document", type_="foreignkey")
op.create_foreign_key(
"document_report_id_fkey",
"document",
"report",
["report_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"document_incident_id_fkey",
"document",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"document_project_id_fkey",
"document",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.add_column(
"dispatch_user_project",
sa.Column(
"id",
sa.INTEGER(),
server_default=sa.text("nextval('public.dispatch_user_project_id_seq'::regclass)"),
autoincrement=True,
nullable=False,
),
)
op.drop_constraint(None, "dispatch_user_project", type_="foreignkey")
op.drop_constraint(None, "dispatch_user_project", type_="foreignkey")
op.create_foreign_key(
"dispatch_user_project_dispatch_user_id_fkey",
"dispatch_user_project",
"dispatch_user",
["dispatch_user_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"dispatch_user_project_project_id_fkey",
"dispatch_user_project",
"project",
["project_id"],
["id"],
referent_schema="public",
)
op.alter_column(
"dispatch_user_project", "project_id", existing_type=sa.INTEGER(), nullable=True
)
op.alter_column(
"dispatch_user_project", "dispatch_user_id", existing_type=sa.INTEGER(), nullable=True
)
op.drop_constraint(None, "definition_terms", type_="foreignkey")
op.drop_constraint(None, "definition_terms", type_="foreignkey")
op.create_foreign_key(
"definition_terms_definition_id_fkey",
"definition_terms",
"definition",
["definition_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"definition_terms_term_id_fkey",
"definition_terms",
"term",
["term_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "definition_teams", type_="foreignkey")
op.drop_constraint(None, "definition_teams", type_="foreignkey")
op.create_foreign_key(
"definition_teams_team_contact_id_fkey",
"definition_teams",
"team_contact",
["team_contact_id"],
["id"],
referent_schema="public",
)
op.create_foreign_key(
"definition_teams_definition_id_fkey",
"definition_teams",
"definition",
["definition_id"],
["id"],
referent_schema="public",
)
op.drop_constraint(None, "definition", type_="foreignkey")
op.create_foreign_key(
"definition_project_id_fkey",
"definition",
"project",
["project_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "conversation", type_="foreignkey")
op.create_foreign_key(
"conversation_incident_id_fkey",
"conversation",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "conference", type_="foreignkey")
op.create_foreign_key(
"conference_incident_id_fkey",
"conference",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_team_contact_filters", type_="foreignkey")
op.drop_constraint(None, "assoc_team_contact_filters", type_="foreignkey")
op.create_foreign_key(
"assoc_team_contact_filters_team_contact_id_fkey",
"assoc_team_contact_filters",
"team_contact",
["team_contact_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_team_contact_filters_search_filter_id_fkey",
"assoc_team_contact_filters",
"search_filter",
["search_filter_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_service_filters", type_="foreignkey")
op.drop_constraint(None, "assoc_service_filters", type_="foreignkey")
op.create_foreign_key(
"assoc_service_filters_search_filter_id_fkey",
"assoc_service_filters",
"search_filter",
["search_filter_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_service_filters_service_id_fkey",
"assoc_service_filters",
"service",
["service_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_notification_filters", type_="foreignkey")
op.drop_constraint(None, "assoc_notification_filters", type_="foreignkey")
op.create_foreign_key(
"assoc_notification_filters_notification_id_fkey",
"assoc_notification_filters",
"notification",
["notification_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_notification_filters_search_filter_id_fkey",
"assoc_notification_filters",
"search_filter",
["search_filter_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_individual_contact_filters", type_="foreignkey")
op.drop_constraint(None, "assoc_individual_contact_filters", type_="foreignkey")
op.create_foreign_key(
"assoc_individual_contact_filters_individual_contact_id_fkey",
"assoc_individual_contact_filters",
"individual_contact",
["individual_contact_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_individual_contact_filters_search_filter_id_fkey",
"assoc_individual_contact_filters",
"search_filter",
["search_filter_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_incident_terms", type_="foreignkey")
op.drop_constraint(None, "assoc_incident_terms", type_="foreignkey")
op.create_foreign_key(
"assoc_incident_terms_term_id_fkey",
"assoc_incident_terms",
"term",
["term_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_incident_terms_incident_id_fkey",
"assoc_incident_terms",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_incident_tags", type_="foreignkey")
op.drop_constraint(None, "assoc_incident_tags", type_="foreignkey")
op.create_foreign_key(
"assoc_incident_tags_tag_id_fkey",
"assoc_incident_tags",
"tag",
["tag_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_incident_tags_incident_id_fkey",
"assoc_incident_tags",
"incident",
["incident_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.drop_constraint(None, "assoc_document_filters", type_="foreignkey")
op.drop_constraint(None, "assoc_document_filters", type_="foreignkey")
op.create_foreign_key(
"assoc_document_filters_search_filter_id_fkey",
"assoc_document_filters",
"search_filter",
["search_filter_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_foreign_key(
"assoc_document_filters_document_id_fkey",
"assoc_document_filters",
"document",
["document_id"],
["id"],
referent_schema="public",
ondelete="CASCADE",
)
op.create_table(
"recommendation_accuracy",
sa.Column(
"id",
sa.INTEGER(),
server_default=sa.text("nextval('public.recommendation_accuracy_id_seq'::regclass)"),
autoincrement=True,
nullable=False,
),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("correct", sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column("resource_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("resource_type", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_accuracy_recommendation_id_fkey",
),
sa.PrimaryKeyConstraint("id", name="recommendation_accuracy_pkey"),
)
op.create_table(
"recommendation_team_contacts",
sa.Column("team_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_team_contacts_recommendation_id_fkey",
),
sa.ForeignKeyConstraint(
["team_contact_id"],
["public.team_contact.id"],
name="recommendation_team_contacts_team_contact_id_fkey",
),
sa.PrimaryKeyConstraint(
"team_contact_id", "recommendation_id", name="recommendation_team_contacts_pkey"
),
)
op.create_table(
"team_contact_incident_type",
sa.Column("incident_type_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("team_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_type_id"],
["public.incident_type.id"],
name="team_contact_incident_type_incident_type_id_fkey",
),
sa.ForeignKeyConstraint(
["team_contact_id"],
["public.team_contact.id"],
name="team_contact_incident_type_team_contact_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_type_id", "team_contact_id", name="team_contact_incident_type_pkey"
),
)
op.create_table(
"service_terms",
sa.Column("term_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("service_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["service_id"], ["public.service.id"], name="service_terms_service_id_fkey"
),
sa.ForeignKeyConstraint(["term_id"], ["public.term.id"], name="service_terms_term_id_fkey"),
sa.PrimaryKeyConstraint("term_id", "service_id", name="service_terms_pkey"),
)
op.create_table(
"recommendation_services",
sa.Column("service_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_services_recommendation_id_fkey",
),
sa.ForeignKeyConstraint(
["service_id"], ["public.service.id"], name="recommendation_services_service_id_fkey"
),
sa.PrimaryKeyConstraint(
"service_id", "recommendation_id", name="recommendation_services_pkey"
),
)
op.create_table(
"document_incident_type",
sa.Column("incident_type_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("document_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["document_id"], ["public.document.id"], name="document_incident_type_document_id_fkey"
),
sa.ForeignKeyConstraint(
["incident_type_id"],
["public.incident_type.id"],
name="document_incident_type_incident_type_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_type_id", "document_id", name="document_incident_type_pkey"
),
)
op.create_table(
"service_incident_priority",
sa.Column("incident_priority_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("service_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_priority_id"],
["public.incident_priority.id"],
name="service_incident_priority_incident_priority_id_fkey",
),
sa.ForeignKeyConstraint(
["service_id"], ["public.service.id"], name="service_incident_priority_service_id_fkey"
),
sa.PrimaryKeyConstraint(
"incident_priority_id", "service_id", name="service_incident_priority_pkey"
),
)
op.create_table(
"document_incident_priority",
sa.Column("incident_priority_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("document_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["document_id"],
["public.document.id"],
name="document_incident_priority_document_id_fkey",
),
sa.ForeignKeyConstraint(
["incident_priority_id"],
["public.incident_priority.id"],
name="document_incident_priority_incident_priority_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_priority_id", "document_id", name="document_incident_priority_pkey"
),
)
op.create_table(
"recommendation_incident_priorities",
sa.Column("incident_priority_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_priority_id"],
["public.incident_priority.id"],
name="recommendation_incident_priorities_incident_priority_id_fkey",
),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_incident_priorities_recommendation_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_priority_id",
"recommendation_id",
name="recommendation_incident_priorities_pkey",
),
)
op.create_table(
"assoc_individual_contact_incident_type",
sa.Column("incident_type_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("individual_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_type_id"],
["public.incident_type.id"],
name="assoc_individual_contact_incident_type_incident_type_id_fkey",
),
sa.ForeignKeyConstraint(
["individual_contact_id"],
["public.individual_contact.id"],
name="assoc_individual_contact_incident_ty_individual_contact_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_type_id",
"individual_contact_id",
name="assoc_individual_contact_incident_type_pkey",
),
)
op.create_table(
"recommendation_incident_types",
sa.Column("incident_type_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_type_id"],
["public.incident_type.id"],
name="recommendation_incident_types_incident_type_id_fkey",
),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_incident_types_recommendation_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_type_id", "recommendation_id", name="recommendation_incident_types_pkey"
),
)
op.create_table(
"assoc_individual_contact_terms",
sa.Column("term_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("individual_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["individual_contact_id"],
["public.individual_contact.id"],
name="assoc_individual_contact_terms_individual_contact_id_fkey",
),
sa.ForeignKeyConstraint(
["term_id"], ["public.term.id"], name="assoc_individual_contact_terms_term_id_fkey"
),
sa.PrimaryKeyConstraint(
"term_id", "individual_contact_id", name="assoc_individual_contact_terms_pkey"
),
)
op.create_table(
"recommendation_individual_contacts",
sa.Column("individual_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["individual_contact_id"],
["public.individual_contact.id"],
name="recommendation_individual_contacts_individual_contact_id_fkey",
),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_individual_contacts_recommendation_id_fkey",
),
sa.PrimaryKeyConstraint(
"individual_contact_id",
"recommendation_id",
name="recommendation_individual_contacts_pkey",
),
)
op.create_table(
"team_contact_incident_priority",
sa.Column("incident_priority_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("team_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_priority_id"],
["public.incident_priority.id"],
name="team_contact_incident_priority_incident_priority_id_fkey",
),
sa.ForeignKeyConstraint(
["team_contact_id"],
["public.team_contact.id"],
name="team_contact_incident_priority_team_contact_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_priority_id", "team_contact_id", name="team_contact_incident_priority_pkey"
),
)
op.create_table(
"recommendation_terms",
sa.Column("term_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_terms_recommendation_id_fkey",
),
sa.ForeignKeyConstraint(
["term_id"], ["public.term.id"], name="recommendation_terms_term_id_fkey"
),
sa.PrimaryKeyConstraint("term_id", "recommendation_id", name="recommendation_terms_pkey"),
)
op.create_table(
"assoc_individual_contact_incident_priority",
sa.Column("incident_priority_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("individual_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_priority_id"],
["public.incident_priority.id"],
name="assoc_individual_contact_incident_pri_incident_priority_id_fkey",
),
sa.ForeignKeyConstraint(
["individual_contact_id"],
["public.individual_contact.id"],
name="assoc_individual_contact_incident_pr_individual_contact_id_fkey",
),
sa.PrimaryKeyConstraint(
"incident_priority_id",
"individual_contact_id",
name="assoc_individual_contact_incident_priority_pkey",
),
)
op.create_table(
"service_incident_type",
sa.Column("incident_type_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("service_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["incident_type_id"],
["public.incident_type.id"],
name="service_incident_type_incident_type_id_fkey",
),
sa.ForeignKeyConstraint(
["service_id"], ["public.service.id"], name="service_incident_type_service_id_fkey"
),
sa.PrimaryKeyConstraint(
"incident_type_id", "service_id", name="service_incident_type_pkey"
),
)
op.create_table(
"recommendation_documents",
sa.Column("document_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("recommendation_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["document_id"],
["public.document.id"],
name="recommendation_documents_document_id_fkey",
),
sa.ForeignKeyConstraint(
["recommendation_id"],
["public.recommendation.id"],
name="recommendation_documents_recommendation_id_fkey",
),
sa.PrimaryKeyConstraint(
"document_id", "recommendation_id", name="recommendation_documents_pkey"
),
)
op.create_table(
"team_contact_terms",
sa.Column("term_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("team_contact_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["team_contact_id"],
["public.team_contact.id"],
name="team_contact_terms_team_contact_id_fkey",
),
sa.ForeignKeyConstraint(
["term_id"], ["public.term.id"], name="team_contact_terms_term_id_fkey"
),
sa.PrimaryKeyConstraint("term_id", "team_contact_id", name="team_contact_terms_pkey"),
)
op.create_table(
"document_terms",
sa.Column("term_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("document_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["document_id"],
["public.document.id"],
name="document_terms_document_id_fkey",
ondelete="CASCADE",
),
sa.ForeignKeyConstraint(
["term_id"], ["public.term.id"], name="document_terms_term_id_fkey", ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("term_id", "document_id", name="document_terms_pkey"),
)