Skip to content

Commit a1c8ad6

Browse files
Fix creator_id migration
1 parent a65c937 commit a1c8ad6

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

notifications/lib/notifications/api/public_api/create.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule Notifications.Api.PublicApi.Create do
1515

1616
with {:ok, :authorized} <- Auth.can_manage?(user_id, org_id),
1717
{:ok, :valid} <- Validator.validate(notification),
18-
{:ok, n} <- create_notification(org_id, notification) do
18+
{:ok, n} <- create_notification(org_id, user_id, notification) do
1919
Serialization.serialize(n)
2020
else
2121
{:error, :permission_denied} ->
@@ -36,13 +36,13 @@ defmodule Notifications.Api.PublicApi.Create do
3636
end
3737
end
3838

39-
def create_notification(org_id, notification) do
39+
def create_notification(org_id, creator_id, notification) do
4040
Repo.transaction(fn ->
4141
n =
4242
Models.Notification.new(
4343
org_id,
4444
notification.metadata.name,
45-
notification.metadata.creator_id,
45+
creator_id,
4646
Notifications.Util.Transforms.encode_spec(notification.spec)
4747
)
4848

notifications/lib/notifications/models/notification.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule Notifications.Models.Notification do
1212
has_many(:rules, Notifications.Models.Rule, on_delete: :delete_all)
1313

1414
field(:org_id, :binary_id)
15+
field(:creator_id, :binary_id)
1516
field(:name, :string)
1617
field(:spec, :map)
1718

notifications/priv/repo/migrations/20250804163140_add_creator_id_to_notifications.exs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Notifications.Repo.Migrations.AddCreatorIdToNotifications do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:notifications) do
6+
add :creator_id, :binary_id, null: true
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)