Commit 8a7cd25d authored by Andreas Brandl's avatar Andreas Brandl

For MySQL, foreign keys are dependent on index.

parent 43b74afd
...@@ -10,9 +10,6 @@ class CreateUserInteractedProjectsTable < ActiveRecord::Migration ...@@ -10,9 +10,6 @@ class CreateUserInteractedProjectsTable < ActiveRecord::Migration
t.references :user, null: false t.references :user, null: false
t.references :project, null: false t.references :project, null: false
end 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 end
def down def down
......
...@@ -14,11 +14,17 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration ...@@ -14,11 +14,17 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration
end.up end.up
add_concurrent_index :user_interacted_projects, [:project_id, :user_id], unique: true 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 end
def down def down
execute "TRUNCATE user_interacted_projects" 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' remove_concurrent_index_by_name :user_interacted_projects, 'index_user_interacted_projects_on_project_id_and_user_id'
end end
......
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