Make CreateGeoNodeNamespaceLinks migration simpler

parent aba6d7d2
......@@ -5,26 +5,14 @@ class CreateGeoNodeNamespaceLinks < ActiveRecord::Migration
disable_ddl_transaction!
def up
def change
create_table :geo_node_namespace_links do |t|
t.references :geo_node, index: true, foreign_key: { on_delete: :cascade }, null: false
t.integer :namespace_id, null: false
end
add_timestamps_with_timezone :geo_node_namespace_links
add_concurrent_foreign_key :geo_node_namespace_links, :namespaces, column: :namespace_id, on_delete: :cascade
t.references :namespace, foreign_key: { on_delete: :cascade }, null: false
add_concurrent_index :geo_node_namespace_links, [:geo_node_id, :namespace_id], unique: true
end
def down
remove_foreign_key :geo_node_namespace_links, column: :namespace_id
if index_exists?(:geo_node_namespace_links, [:geo_node_id, :namespace_id])
remove_concurrent_index :geo_node_namespace_links, [:geo_node_id, :namespace_id]
t.index [:geo_node_id, :namespace_id], unique: true
end
drop_table :geo_node_namespace_links
add_timestamps_with_timezone :geo_node_namespace_links
end
end
......@@ -1993,7 +1993,7 @@ ActiveRecord::Schema.define(version: 20170803130232) do
add_foreign_key "geo_event_log", "geo_repository_renamed_events", column: "repository_renamed_event_id", name: "fk_86c84214ec", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_repository_updated_events", column: "repository_updated_event_id", on_delete: :cascade
add_foreign_key "geo_node_namespace_links", "geo_nodes", on_delete: :cascade
add_foreign_key "geo_node_namespace_links", "namespaces", name: "fk_41ff5fb854", on_delete: :cascade
add_foreign_key "geo_node_namespace_links", "namespaces", on_delete: :cascade
add_foreign_key "geo_repositories_changed_events", "geo_nodes", on_delete: :cascade
add_foreign_key "geo_repository_renamed_events", "projects", on_delete: :cascade
add_foreign_key "geo_repository_updated_events", "projects", on_delete: :cascade
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment