defmodule AshPostgres.TestRepo.TenantMigrations.MigrateResources1 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 tenants = if prefix() do [prefix()] else repo().all_tenants() end for prefix <- tenants do create table(:multitenant_posts, primary_key: false, prefix: prefix) do add(:id, :binary_id, null: true, default: fragment("uuid_generate_v4()"), primary_key: true ) add( :org_id, references("multitenant_orgs", type: :binary_id, column: :id, name: "#{prefix}_multitenant_orgs_org_id_fkey", prefix: "public" ), default: nil, primary_key: false ) add(:name, :text, null: true, default: nil, primary_key: false) end end end def down() do tenants = if prefix() do [prefix()] else repo().all_tenants() end for prefix <- tenants do drop(table("multitenant_posts", prefix: prefix)) end end end