mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +12:00
fbc42ce87a
feat: add `mix ash_postgres.create` feat: add `mix ash_postgres.migrate` feat: add `mix ash_postgres.migrate --tenants` feat: add `mix ash_postgres.drop`
54 lines
1.6 KiB
Elixir
54 lines
1.6 KiB
Elixir
defmodule AshPostgres.TestRepo.Migrations.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
|
|
execute("CREATE EXTENSION \"citext\";")
|
|
execute("CREATE EXTENSION \"uuid-ossp\";")
|
|
execute("CREATE EXTENSION \"pg_trgm\";")
|
|
|
|
create table(:posts, primary_key: false) do
|
|
add :id, :binary_id, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
|
|
add :title, :text
|
|
add :score, :integer
|
|
add :public, :boolean
|
|
add :category, :citext
|
|
end
|
|
|
|
create table(:multitenant_orgs, primary_key: false) do
|
|
add :id, :binary_id, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
|
|
add :name, :text
|
|
end
|
|
|
|
create unique_index(:multitenant_orgs, [:id, :name],
|
|
name: "multitenant_orgs_unique_by_name_unique_index"
|
|
)
|
|
|
|
create table(:comments, primary_key: false) do
|
|
add :id, :binary_id, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
|
|
add :title, :text
|
|
add :post_id, references("posts", type: :binary_id, column: :id)
|
|
end
|
|
end
|
|
|
|
def down do
|
|
drop table("comments")
|
|
|
|
drop_if_exists unique_index(:multitenant_orgs, [:id, :name],
|
|
name: "multitenant_orgs_unique_by_name_unique_index"
|
|
)
|
|
|
|
drop table("multitenant_orgs")
|
|
|
|
drop table("posts")
|
|
|
|
execute("DROP EXTENSION \"citext\"")
|
|
execute("DROP EXTENSION \"uuid-ossp\"")
|
|
execute("DROP EXTENSION \"pg_trgm\"")
|
|
end
|
|
end
|