Current section

Files

Jump to
dryad lib dryad migrations postgres v01.ex
Raw

lib/dryad/migrations/postgres/v01.ex

defmodule Dryad.Migrations.Postgres.V01 do
use Ecto.Migration
def up(_opts) do
create table(:service_accounts, primary_key: false) do
add(:id, :uuid,
primary_key: true,
default: fragment("uuid_generate_v4()")
)
add(:name, :string, null: false)
add(:secret, :string, null: false)
add(
:organization,
references(:organizations, type: :uuid, on_delete: :delete_all),
null: false
)
add(:user, references(:users, type: :uuid, on_delete: :delete_all),
null: false
)
add(:inserted_at, :naive_datetime,
null: false,
default: fragment("now()")
)
add(:updated_at, :naive_datetime, null: false, default: fragment("now()"))
end
create(unique_index(:service_accounts, [:name]))
end
def down(_opts) do
drop(table(:service_accounts))
end
end