Adding likes to tweets
This commit is contained in:
47
priv/repo/migrations/20260331182608_add_tweet_likes.exs
Normal file
47
priv/repo/migrations/20260331182608_add_tweet_likes.exs
Normal file
@@ -0,0 +1,47 @@
|
||||
defmodule Mixer.Repo.Migrations.AddTweetLikes 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(:tweet_likes, primary_key: false) do
|
||||
add :id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true
|
||||
|
||||
add :tweet_id,
|
||||
references(:tweets,
|
||||
column: :id,
|
||||
name: "tweet_likes_tweet_id_fkey",
|
||||
type: :uuid,
|
||||
prefix: "public"
|
||||
), null: false
|
||||
|
||||
add :user_id,
|
||||
references(:users,
|
||||
column: :id,
|
||||
name: "tweet_likes_user_id_fkey",
|
||||
type: :uuid,
|
||||
prefix: "public"
|
||||
), null: false
|
||||
end
|
||||
|
||||
create unique_index(:tweet_likes, [:tweet_id, :user_id],
|
||||
name: "tweet_likes_unique_user_tweet_index"
|
||||
)
|
||||
end
|
||||
|
||||
def down do
|
||||
drop_if_exists unique_index(:tweet_likes, [:tweet_id, :user_id],
|
||||
name: "tweet_likes_unique_user_tweet_index"
|
||||
)
|
||||
|
||||
drop constraint(:tweet_likes, "tweet_likes_tweet_id_fkey")
|
||||
|
||||
drop constraint(:tweet_likes, "tweet_likes_user_id_fkey")
|
||||
|
||||
drop table(:tweet_likes)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user