Skip to content

Commit b6767c9

Browse files
committed
fix: add migration for rbac ce subject type
1 parent 5748458 commit b6767c9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
defmodule Rbac.Repo.Migrations.AddSubjectTypeToRoleAssignment do
2+
use Ecto.Migration
3+
4+
import Ecto.Query
5+
6+
def change do
7+
alter table(:role_assignment) do
8+
add(:subject_type, :string, default: "user")
9+
end
10+
11+
execute(&execute_up/0, &execute_down/0)
12+
end
13+
14+
defp execute_up do
15+
repo().update_all(
16+
from(r in Rbac.Models.RoleAssignment,
17+
where: is_nil(r.subject_type)
18+
),
19+
set: [subject_type: "user"]
20+
)
21+
end
22+
23+
defp execute_down, do: :ok
24+
end

0 commit comments

Comments
 (0)