Skip to content

Commit

Permalink
remove constraints #176
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Feb 6, 2022
1 parent de2671e commit f90ecb6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Auth.Repo.Migrations.AddPersonIdToTag do

def change do
alter table(:tags) do
add :person_id, references(:people, on_delete: :nothing)
add :person_id, references(:people, on_delete: :delete_all)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Auth.Repo.Migrations.AddPersonIdToStatus do

def change do
alter table(:status) do
add :person_id, references(:people, on_delete: :nothing)
add :person_id, references(:people, on_delete: :delete_all)
end
end
end
2 changes: 1 addition & 1 deletion priv/repo/migrations/20200722175850_create_roles.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Auth.Repo.Migrations.CreateRoles do
create table(:roles) do
add :name, :string
add :desc, :string
add :person_id, references(:people, on_delete: :nothing)
add :person_id, references(:people, on_delete: :delete_all)
add :app_id, references(:apps, on_delete: :nothing)

timestamps()
Expand Down
2 changes: 1 addition & 1 deletion priv/repo/migrations/20200722180019_create_permissions.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Auth.Repo.Migrations.CreatePermissions do
create table(:permissions) do
add :name, :string
add :desc, :string
add :person_id, references(:people, on_delete: :nothing)
add :person_id, references(:people, on_delete: :delete_all)

timestamps()
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Auth.Repo.Migrations.CreatePeopleRoles do

def change do
create table(:people_roles) do
add :person_id, references(:people, on_delete: :nothing)
add :person_id, references(:people, on_delete: :delete_all)
add :role_id, references(:roles, on_delete: :nothing)
add :granter_id, references(:people, on_delete: :nothing)
# elixirforum.com/t/difference-between-utc-datetime-and-naive-datetime/12551
Expand Down
2 changes: 1 addition & 1 deletion priv/repo/migrations/20200912235027_add_app_id_people.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Auth.Repo.Migrations.AddAppIdPeople do

def change do
alter table(:people) do
add :app_id, references(:apps, on_delete: :nothing)
add :app_id, references(:apps, on_delete: :delete_all)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Auth.Repo.Migrations.AddAppIdToSessions do
add :end, :naive_datetime
# avoid tight coupling
remove :person_id
add :person_id, references(:people, on_delete: :nothing)
add :person_id, references(:people, on_delete: :delete_all)
add :user_agent_id, :integer
# Don't want to risk leaking auth/refresh tokens in a breach
# so just not going to store them even encrypted.
Expand Down
14 changes: 14 additions & 0 deletions priv/repo/migrations/20220206235425_remove_constraints.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule Auth.Repo.Migrations.RemoveConstraints do
use Ecto.Migration

def change do
# drop(constraint(:status, :status_person_id_fkey))
drop(constraint(:apps, :apps_person_id_fkey))
drop(constraint(:apps, :apps_status_fkey))
drop(constraint(:apikeys, :apikeys_person_id_fkey))
drop(constraint(:apikeys, :apikeys_status_fkey))
drop(constraint(:roles, :roles_person_id_fkey))
# drop(constraint(:people_roles, :people_roles_person_id_fkey))
# drop(constraint(:people_roles, :people_roles_granter_id_fkey))
end
end

0 comments on commit f90ecb6

Please sign in to comment.