mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
25 lines
497 B
Elixir
25 lines
497 B
Elixir
defmodule Plausible.Repo.Migrations.AddApiKeyScopes do
|
|
use Ecto.Migration
|
|
|
|
def up do
|
|
alter table(:api_keys) do
|
|
add :scopes, {:array, :text}
|
|
end
|
|
|
|
execute "UPDATE api_keys SET scopes='{stats:read:*}'"
|
|
|
|
alter table(:api_keys) do
|
|
modify :scopes, {:array, :text}, null: false
|
|
end
|
|
|
|
# https://stackoverflow.com/a/4059785
|
|
create index(:api_keys, [:scopes], using: "GIN")
|
|
end
|
|
|
|
def down do
|
|
alter table(:api_keys) do
|
|
remove :scopes
|
|
end
|
|
end
|
|
end
|