Skip to content

Commit

Permalink
Create migration adding is_autocreated to team_memberships
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Jan 22, 2025
1 parent 48bd2fb commit 100dbc4
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defmodule Plausible.Repo.Migrations.AddAutocreatedToTeamMemberships do
use Ecto.Migration

def change do
alter table(:team_memberships) do
add :is_autocreated, :boolean, null: false, default: false
end

create unique_index(:team_memberships, [:user_id],
where: "role = 'owner' and is_autocreated = true",
name: :one_autocreated_owner_per_user
)

execute """
UPDATE team_memberships SET is_autocreated = true WHERE role = 'owner'
""",
"""
SELECT 1
"""
end
end

0 comments on commit 100dbc4

Please sign in to comment.