mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +12:00
59 lines
1.2 KiB
Elixir
59 lines
1.2 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")
|
||
|
|
||
|
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
|