Working follow and unfollow interactions for users
This commit is contained in:
53
priv/repo/migrations/20260403012654_follow_feature.exs
Normal file
53
priv/repo/migrations/20260403012654_follow_feature.exs
Normal file
@@ -0,0 +1,53 @@
|
||||
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
|
||||
Reference in New Issue
Block a user