Skip to content

Commit

Permalink
Remove foreign key constraints referencing nodes table
Browse files Browse the repository at this point in the history
  • Loading branch information
kevbuchanan authored and Naren Chainani committed Mar 31, 2016
1 parent 8316c7c commit 72d0030
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace :db do
desc "rollback one migration"
task :rollback => :env do
DB.with_connection do |c|
Foreigner.load
ActiveRecord::Migrator.rollback('db/migrations')
end
end
Expand Down
15 changes: 15 additions & 0 deletions db/migrations/014_remove_foreign_keys.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class RemoveForeignKeys < ActiveRecord::Migration
def up
remove_foreign_key(:client_node_details, :nodes)
remove_foreign_key(:node_details, :nodes)
remove_foreign_key(:status_changes, :nodes)
remove_foreign_key(:nodes, name: 'nodes_parent_id_fk')
end

def down
add_foreign_key(:client_node_details, :nodes)
add_foreign_key(:node_details, :nodes)
add_foreign_key(:status_changes, :nodes)
add_foreign_key(:nodes, :nodes, column: 'parent_id')
end
end
21 changes: 11 additions & 10 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 11) do
ActiveRecord::Schema.define(version: 14) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -38,24 +38,25 @@
add_index "node_details", ["node_id"], name: "index_node_details_on_node_id", unique: true, using: :btree

create_table "nodes", id: :uuid, default: "uuid_generate_v4()", force: true do |t|
t.string "mode", null: false
t.string "current_server_status", null: false
t.string "current_client_status", null: false
t.string "name", null: false
t.string "mode", null: false
t.string "current_server_status", null: false
t.string "current_client_status", null: false
t.string "name", null: false
t.datetime "fires_at"
t.uuid "parent_id"
t.uuid "workflow_id", null: false
t.uuid "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "seq", null: false
t.uuid "workflow_id", null: false
t.uuid "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "seq", limit: 8, default: "nextval('nodes_seq_seq'::regclass)", null: false
t.uuid "parent_link_id"
end

add_index "nodes", ["fires_at"], name: "index_nodes_on_fires_at", using: :btree
add_index "nodes", ["parent_id"], name: "index_nodes_on_parent_id", using: :btree
add_index "nodes", ["parent_link_id"], name: "index_nodes_on_parent_link_id", using: :btree
add_index "nodes", ["seq"], name: "index_nodes_on_seq", unique: true, using: :btree
add_index "nodes", ["workflow_id", "seq", "parent_id"], name: "index_nodes_on_workflow_id_and_seq_and_parent_id", using: :btree
add_index "nodes", ["workflow_id"], name: "index_nodes_on_workflow_id", using: :btree

create_table "status_changes", force: true do |t|
Expand Down

0 comments on commit 72d0030

Please sign in to comment.