54 lines
1.5 KiB
Elixir
54 lines
1.5 KiB
Elixir
defmodule Mixer.Repo.Migrations.FollowFeature 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(:follows, primary_key: false) do
|
|
add :id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true
|
|
|
|
add :created_at, :utc_datetime_usec,
|
|
null: false,
|
|
default: fragment("(now() AT TIME ZONE 'utc')")
|
|
|
|
add :follower_id,
|
|
references(:users,
|
|
column: :id,
|
|
name: "follows_follower_id_fkey",
|
|
type: :uuid,
|
|
prefix: "public",
|
|
on_delete: :delete_all
|
|
), primary_key: true, null: false
|
|
|
|
add :following_id,
|
|
references(:users,
|
|
column: :id,
|
|
name: "follows_following_id_fkey",
|
|
type: :uuid,
|
|
prefix: "public",
|
|
on_delete: :delete_all
|
|
), primary_key: true, null: false
|
|
end
|
|
|
|
create unique_index(:follows, [:follower_id, :following_id],
|
|
name: "follows_unique_follow_index"
|
|
)
|
|
end
|
|
|
|
def down do
|
|
drop_if_exists unique_index(:follows, [:follower_id, :following_id],
|
|
name: "follows_unique_follow_index"
|
|
)
|
|
|
|
drop constraint(:follows, "follows_follower_id_fkey")
|
|
|
|
drop constraint(:follows, "follows_following_id_fkey")
|
|
|
|
drop table(:follows)
|
|
end
|
|
end
|