-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change roles to
admin
, manage
, and view
and switch to varchars instead of Postgres Enums
- Loading branch information
1 parent
e63f0a2
commit ff90726
Showing
33 changed files
with
108 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
priv/repo/migrations/20231221105046_switch_role_to_varchar.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule NervesHub.Repo.Migrations.SwitchRoleToVarchar do | ||
use Ecto.Migration | ||
|
||
def change do | ||
execute "ALTER TABLE org_users ALTER COLUMN role TYPE varchar;" | ||
execute "ALTER TABLE product_users ALTER COLUMN role TYPE varchar;" | ||
|
||
execute "UPDATE org_users SET role = 'admin' WHERE role = 'delete';" | ||
execute "UPDATE org_users SET role = 'manage' WHERE role = 'write';" | ||
execute "UPDATE org_users SET role = 'view' WHERE role = 'read';" | ||
|
||
execute "UPDATE product_users SET role = 'admin' WHERE role = 'delete';" | ||
execute "UPDATE product_users SET role = 'manage' WHERE role = 'write';" | ||
execute "UPDATE product_users SET role = 'view' WHERE role = 'read';" | ||
|
||
execute "DROP TYPE role;" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,7 +224,7 @@ defmodule NervesHub.AccountsTest do | |
|
||
{:ok, %Invite{} = invite} = | ||
Accounts.add_or_invite_to_org( | ||
%{"email" => "[email protected]", "role" => "read"}, | ||
%{"email" => "[email protected]", "role" => "view"}, | ||
org | ||
) | ||
|
||
|
@@ -240,7 +240,7 @@ defmodule NervesHub.AccountsTest do | |
|
||
{:ok, %Invite{} = invite} = | ||
Accounts.add_or_invite_to_org( | ||
%{"email" => "[email protected]", "role" => "read"}, | ||
%{"email" => "[email protected]", "role" => "view"}, | ||
org | ||
) | ||
|
||
|
@@ -254,10 +254,10 @@ defmodule NervesHub.AccountsTest do | |
new_user = Fixtures.user_fixture() | ||
|
||
assert {:ok, %OrgUser{}} = | ||
Accounts.add_or_invite_to_org(%{"email" => new_user.email, "role" => "read"}, org) | ||
Accounts.add_or_invite_to_org(%{"email" => new_user.email, "role" => "view"}, org) | ||
|
||
{:error, changeset} = | ||
Accounts.add_or_invite_to_org(%{"email" => new_user.email, "role" => "read"}, org) | ||
Accounts.add_or_invite_to_org(%{"email" => new_user.email, "role" => "view"}, org) | ||
|
||
assert "is already member" in errors_on(changeset).org_users | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ defmodule NervesHub.Accounts.RemoveAccountTest do | |
org2 = Fixtures.org_fixture(user, %{name: "Test-Org2"}) | ||
|
||
{:ok, invite} = | ||
Accounts.add_or_invite_to_org(%{"email" => "[email protected]", "role" => "read"}, org2) | ||
Accounts.add_or_invite_to_org(%{"email" => "[email protected]", "role" => "view"}, org2) | ||
|
||
params = %{username: "Test-User2", password: "Test-Password"} | ||
{:ok, org_user} = Accounts.create_user_from_invite(invite, org2, params) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.