mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +12:00
37 lines
1 KiB
Elixir
37 lines
1 KiB
Elixir
|
defmodule AshPostgres.TestRepo.Migrations.MigrateResources2 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
|
||
|
create table(:post_ratings, primary_key: false) do
|
||
|
add :id, :binary_id, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
|
||
|
add :score, :integer
|
||
|
add :resource_id, :binary_id
|
||
|
end
|
||
|
|
||
|
create table(:comment_ratings, primary_key: false) do
|
||
|
add :id, :binary_id, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
|
||
|
add :score, :integer
|
||
|
add :resource_id, references("comments", type: :binary_id, column: :id)
|
||
|
end
|
||
|
|
||
|
alter table(:post_ratings) do
|
||
|
modify :resource_id, references("posts", type: :binary_id, column: :id)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def down do
|
||
|
alter table(:post_ratings) do
|
||
|
modify :resource_id, :binary_id
|
||
|
end
|
||
|
|
||
|
drop table("comment_ratings")
|
||
|
|
||
|
drop table("post_ratings")
|
||
|
end
|
||
|
end
|