diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180223120443_create_user_interacted_projects_table.rb | 3 | ||||
-rw-r--r-- | db/post_migrate/20180223124427_build_user_interacted_projects_table.rb | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/db/migrate/20180223120443_create_user_interacted_projects_table.rb b/db/migrate/20180223120443_create_user_interacted_projects_table.rb index 8089de45666..20749940b1e 100644 --- a/db/migrate/20180223120443_create_user_interacted_projects_table.rb +++ b/db/migrate/20180223120443_create_user_interacted_projects_table.rb @@ -10,9 +10,6 @@ class CreateUserInteractedProjectsTable < ActiveRecord::Migration t.references :user, null: false t.references :project, null: false end - - add_concurrent_foreign_key :user_interacted_projects, :users, column: :user_id, on_delete: :cascade - add_concurrent_foreign_key :user_interacted_projects, :projects, column: :project_id, on_delete: :cascade end def down diff --git a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb index 0992509c629..4d14dc7b4fb 100644 --- a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb +++ b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb @@ -14,11 +14,17 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration end.up add_concurrent_index :user_interacted_projects, [:project_id, :user_id], unique: true + + add_concurrent_foreign_key :user_interacted_projects, :users, column: :user_id, on_delete: :cascade + add_concurrent_foreign_key :user_interacted_projects, :projects, column: :project_id, on_delete: :cascade end def down execute "TRUNCATE user_interacted_projects" + remove_foreign_key :user_interacted_projects, :users + remove_foreign_key :user_interacted_projects, :projects + remove_concurrent_index_by_name :user_interacted_projects, 'index_user_interacted_projects_on_project_id_and_user_id' end |