mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-28 02:18:50 +00:00
fix(portal): Add managed_by to gateway groups index (#8208)
Some customers have already picked the `Internet` name, which is making our migrations fail. This scopes the unique name index by `managed_by` so that our attempts to create them succeed.
This commit is contained in:
@@ -37,7 +37,7 @@ defmodule Domain.Gateways.Group.Changeset do
|
||||
|> put_default_value(:name, &Domain.NameGenerator.generate/0)
|
||||
|> validate_required(@fields)
|
||||
|> validate_length(:name, min: 1, max: 64)
|
||||
|> unique_constraint(:name, name: :gateway_groups_account_id_name_index)
|
||||
|> unique_constraint(:name, name: :gateway_groups_account_id_name_managed_by_index)
|
||||
end
|
||||
|
||||
def delete(%Gateways.Group{} = group) do
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
defmodule Domain.Repo.Migrations.ScopeGatewayGroupsNameIndexByManagedBy do
|
||||
use Ecto.Migration
|
||||
|
||||
# With the introduction of Internet Sites, some customers may have already named
|
||||
# one of their Sites "Internet". This migration will scope the name constraint to
|
||||
# include the managed_by column.
|
||||
def change do
|
||||
execute("DROP INDEX gateway_groups_account_id_name_index")
|
||||
|
||||
create(
|
||||
index(:gateway_groups, [:account_id, :name, :managed_by],
|
||||
name: :gateway_groups_account_id_name_managed_by_index,
|
||||
unique: true,
|
||||
where: "deleted_at IS NULL"
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user