class AddKeys < ActiveRecord::Migration[5.2]
  def change
    add_foreign_key "farm_events", "devices", name: "farm_events_device_id_fk"
    add_foreign_key "fragments", "devices", name: "fragments_device_id_fk"
    add_foreign_key "logs", "devices", name: "logs_device_id_fk"
    add_foreign_key "plant_templates", "devices", name: "plant_templates_device_id_fk"
    add_foreign_key "plant_templates", "saved_gardens", name: "plant_templates_saved_garden_id_fk"
    add_foreign_key "point_group_items", "point_groups", name: "point_group_items_point_group_id_fk"
    add_foreign_key "point_group_items", "points", name: "point_group_items_point_id_fk"
    add_foreign_key "point_groups", "devices", name: "point_groups_device_id_fk"
    add_foreign_key "saved_gardens", "devices", name: "saved_gardens_device_id_fk"
    add_foreign_key "tools", "devices", name: "tools_device_id_fk"
    add_foreign_key "users", "devices", name: "users_device_id_fk"

    # PROBLEMS- probably need manual cleanup?
    # https://stackoverflow.com/questions/10921144/how-to-find-records-that-violate-referential-integrity
    # add_foreign_key "fbos_configs", "devices", name: "fbos_configs_device_id_fk"
    # add_foreign_key "firmware_configs", "devices", name: "firmware_configs_device_id_fk"
    # add_foreign_key "images", "devices", name: "images_device_id_fk"
    # add_foreign_key "regimens", "devices", name: "regimens_device_id_fk"
    # add_foreign_key "sequences", "devices", name: "sequences_device_id_fk"
    # add_foreign_key "web_app_configs", "devices", name: "web_app_configs_device_id_fk"
    # add_foreign_key "webcam_feeds", "devices", name: "webcam_feeds_device_id_fk"
    # add_foreign_key "edge_nodes", "primary_nodes", name: "edge_nodes_primary_node_id_fk"
    # add_foreign_key "nodes", "nodes", column: "body_id", name: "nodes_body_id_fk"
    # add_foreign_key "nodes", "fragments", name: "nodes_fragment_id_fk"
    # add_foreign_key "nodes", "kinds", name: "nodes_kind_id_fk"
    # add_foreign_key "nodes", "nodes", column: "next_id", name: "nodes_next_id_fk"
    # add_foreign_key "nodes", "nodes", column: "parent_id", name: "nodes_parent_id_fk"
    # add_foreign_key "primitive_pairs", "arg_names", name: "primitive_pairs_arg_name_id_fk"
    # add_foreign_key "primitive_pairs", "arg_sets", name: "primitive_pairs_arg_set_id_fk"
    # add_foreign_key "primitive_pairs", "fragments", name: "primitive_pairs_fragment_id_fk"
    # add_foreign_key "primitive_pairs", "primitives", name: "primitive_pairs_primitive_id_fk"
    # add_foreign_key "primitives", "fragments", name: "primitives_fragment_id_fk"
    # add_foreign_key "regimen_items", "regimens", name: "regimen_items_regimen_id_fk"
    # add_foreign_key "regimen_items", "sequences", name: "regimen_items_sequence_id_fk"
    # add_foreign_key "standard_pairs", "arg_names", name: "standard_pairs_arg_name_id_fk"
    # add_foreign_key "standard_pairs", "arg_sets", name: "standard_pairs_arg_set_id_fk"
    # add_foreign_key "standard_pairs", "fragments", name: "standard_pairs_fragment_id_fk"
    # add_foreign_key "standard_pairs", "nodes", name: "standard_pairs_node_id_fk"
    # add_foreign_key "arg_sets", "fragments", name: "arg_sets_fragment_id_fk"
    # add_foreign_key "arg_sets", "nodes", name: "arg_sets_node_id_fk"
  end
end
