Working follow and unfollow interactions for users

This commit is contained in:
2026-04-02 21:41:27 -04:00
parent f82bc223bb
commit 9c131b98a6
8 changed files with 713 additions and 8 deletions

View 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