ash_postgres/priv/test_repo/migrations/20210419181749_migrate_resources7.exs
2021-04-21 13:50:11 -04:00

64 lines
1.4 KiB
Elixir

defmodule AshPostgres.TestRepo.Migrations.MigrateResources7 do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""
use Ecto.Migration
def up do
alter table(:posts) do
modify :score, :bigint
add :price, :bigint
end
create constraint(:posts, :price_must_be_positive, check: "type = 'sponsored' AND price > 0")
# This is just to ensure tests are trying out the enum migration logic
AshPostgres.Migration.create_enum(AshPostgres.Test.Types.Status)
AshPostgres.Migration.drop_enum(AshPostgres.Test.Types.Status)
AshPostgres.Migration.create_enum(AshPostgres.Test.Types.Status)
alter table(:post_ratings) do
modify :score, :bigint
end
alter table(:integer_posts) do
modify :id, :bigint
end
alter table(:comments) do
modify :likes, :bigint
end
alter table(:comment_ratings) do
modify :score, :bigint
end
end
def down do
alter table(:comment_ratings) do
modify :score, :integer
end
alter table(:comments) do
modify :likes, :integer
end
alter table(:integer_posts) do
modify :id, :integer
end
alter table(:post_ratings) do
modify :score, :integer
end
drop_if_exists constraint(:posts, :price_must_be_positive)
alter table(:posts) do
remove :price
modify :score, :integer
end
end
end