add proper :on_delete behavior
This commit is contained in:
parent
732a4fcbb2
commit
bd6c05f619
@ -17,10 +17,11 @@ defmodule Cannery.Repo.Migrations.CreateUsersAuthTables do
|
|||||||
|
|
||||||
create table(:users_tokens, primary_key: false) do
|
create table(:users_tokens, primary_key: false) do
|
||||||
add :id, :binary_id, primary_key: true
|
add :id, :binary_id, primary_key: true
|
||||||
add :user_id, references(:users, type: :binary_id, on_delete: :delete_all), null: false
|
|
||||||
add :token, :binary, null: false
|
add :token, :binary, null: false
|
||||||
add :context, :string, null: false
|
add :context, :string, null: false
|
||||||
add :sent_to, :string
|
add :sent_to, :string
|
||||||
|
|
||||||
|
add :user_id, references(:users, type: :binary_id, on_delete: :delete_all), null: false
|
||||||
timestamps(updated_at: false)
|
timestamps(updated_at: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ defmodule Cannery.Repo.Migrations.CreateTags do
|
|||||||
add :bg_color, :string
|
add :bg_color, :string
|
||||||
add :text_color, :string
|
add :text_color, :string
|
||||||
|
|
||||||
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
@ -5,10 +5,11 @@ defmodule Cannery.Repo.Migrations.CreateContainers do
|
|||||||
create table(:containers, primary_key: false) do
|
create table(:containers, primary_key: false) do
|
||||||
add :id, :binary_id, primary_key: true
|
add :id, :binary_id, primary_key: true
|
||||||
add :name, :string
|
add :name, :string
|
||||||
add :desc, :string
|
add :desc, :text
|
||||||
add :type, :string
|
add :type, :string
|
||||||
add :location, :string
|
add :location, :text
|
||||||
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
|
|
||||||
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
@ -7,10 +7,11 @@ defmodule Cannery.Repo.Migrations.CreateAmmoGroups do
|
|||||||
add :count, :integer
|
add :count, :integer
|
||||||
add :price_paid, :float
|
add :price_paid, :float
|
||||||
add :notes, :text
|
add :notes, :text
|
||||||
|
|
||||||
add :tag_id, references(:tags, on_delete: :nothing, type: :binary_id)
|
add :tag_id, references(:tags, on_delete: :nothing, type: :binary_id)
|
||||||
add :ammo_type_id, references(:ammo_types, on_delete: :nothing, type: :binary_id)
|
add :ammo_type_id, references(:ammo_types, on_delete: :delete_all, type: :binary_id)
|
||||||
add :container_id, references(:containers, on_delete: :nothing, type: :binary_id)
|
add :container_id, references(:containers, on_delete: :nothing, type: :binary_id)
|
||||||
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,8 @@ defmodule Cannery.Repo.Migrations.CreateInvites do
|
|||||||
add :token, :string
|
add :token, :string
|
||||||
add :uses_left, :integer, default: nil
|
add :uses_left, :integer, default: nil
|
||||||
add :disabled_at, :naive_datetime, default: nil
|
add :disabled_at, :naive_datetime, default: nil
|
||||||
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
|
|
||||||
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user