Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Bruno Marchi
Added: May 19, 2020 3:10 PM
Modified: Nov 29, 2020 9:25 PM
Views: 133
Tags: no tags
  1. create table(:todo_list_items) do
  2.   add :todo_item_id, references(:todo_items)
  3.   add :todo_list_id, references(:todo_lists)
  4.   timestamps()
  5. end
  6.  
  7. def change do
  8.     create table(:user_project, primary_key: false) do
  9.       add(:project_id, references(:project, on_delete: :delete_all), primary_key: true)
  10.       add(:user_id, references(:user, on_delete: :delete_all), primary_key: true)
  11.       timestamps()
  12.     end
  13.  
  14.     create(index(:user_project, [:project_id]))
  15.     create(index(:user_project, [:user_id]))
  16.  
  17.     create(
  18.       unique_index(:user_project, [:user_id, :project_id], name: :user_id_project_id_unique_index)
  19.     )