defmodule Demo.Repo.Migrations.MigrateResources5 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(:users) do modify :id, :uuid end drop constraint(:tickets, "tickets_representative_id_fkey") alter table(:tickets) do modify :id, :uuid end create table(:ticket_comments, primary_key: false) do add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true add :resource_id, :uuid, null: false add :commenting_representative_id, :uuid add :commenting_customer_id, :uuid add :comment, :text end create table(:representative_comments, primary_key: false) do add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true add :resource_id, references(:users, type: :uuid, column: :id) add :commenting_representative_id, references(:users, type: :uuid, column: :id) add :commenting_customer_id, references(:users, type: :uuid, column: :id) add :comment, :text end alter table(:ticket_comments) do modify :commenting_customer_id, references(:users, type: :uuid, column: :id) modify :commenting_representative_id, references(:users, type: :uuid, column: :id) modify :resource_id, references(:tickets, type: :uuid, column: :id) end alter table(:tickets) do modify :reporter_id, :uuid modify :representative_id, references(:users, type: :uuid, column: :id) end end def down do drop constraint(:tickets, "tickets_representative_id_fkey") alter table(:tickets) do modify :representative_id, references(:users, type: :binary_id, column: :id) modify :reporter_id, :binary_id end alter table(:ticket_comments) do modify :resource_id, :uuid modify :commenting_representative_id, :uuid modify :commenting_customer_id, :uuid end drop table(:representative_comments) drop table(:ticket_comments) alter table(:tickets) do modify :id, :binary_id end alter table(:users) do modify :id, :binary_id end end end