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
|
||||
113
priv/resource_snapshots/repo/tweet_likes/20260331182609.json
Normal file
113
priv/resource_snapshots/repo/tweet_likes/20260331182609.json
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"attributes": [
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"gen_random_uuid()\")",
|
||||
"generated?": false,
|
||||
"precision": null,
|
||||
"primary_key?": true,
|
||||
"references": null,
|
||||
"scale": null,
|
||||
"size": null,
|
||||
"source": "id",
|
||||
"type": "uuid"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"precision": null,
|
||||
"primary_key?": false,
|
||||
"references": {
|
||||
"deferrable": false,
|
||||
"destination_attribute": "id",
|
||||
"destination_attribute_default": null,
|
||||
"destination_attribute_generated": null,
|
||||
"index?": false,
|
||||
"match_type": null,
|
||||
"match_with": null,
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"name": "tweet_likes_tweet_id_fkey",
|
||||
"on_delete": null,
|
||||
"on_update": null,
|
||||
"primary_key?": true,
|
||||
"schema": "public",
|
||||
"table": "tweets"
|
||||
},
|
||||
"scale": null,
|
||||
"size": null,
|
||||
"source": "tweet_id",
|
||||
"type": "uuid"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"precision": null,
|
||||
"primary_key?": false,
|
||||
"references": {
|
||||
"deferrable": false,
|
||||
"destination_attribute": "id",
|
||||
"destination_attribute_default": null,
|
||||
"destination_attribute_generated": null,
|
||||
"index?": false,
|
||||
"match_type": null,
|
||||
"match_with": null,
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"name": "tweet_likes_user_id_fkey",
|
||||
"on_delete": null,
|
||||
"on_update": null,
|
||||
"primary_key?": true,
|
||||
"schema": "public",
|
||||
"table": "users"
|
||||
},
|
||||
"scale": null,
|
||||
"size": null,
|
||||
"source": "user_id",
|
||||
"type": "uuid"
|
||||
}
|
||||
],
|
||||
"base_filter": null,
|
||||
"check_constraints": [],
|
||||
"create_table_options": null,
|
||||
"custom_indexes": [],
|
||||
"custom_statements": [],
|
||||
"has_create_action": true,
|
||||
"hash": "8F9732A70AB924AD5FE6FBB20274DFBDB8EDCA638722B29BFA6D8E47C22BF7B6",
|
||||
"identities": [
|
||||
{
|
||||
"all_tenants?": false,
|
||||
"base_filter": null,
|
||||
"index_name": "tweet_likes_unique_user_tweet_index",
|
||||
"keys": [
|
||||
{
|
||||
"type": "atom",
|
||||
"value": "tweet_id"
|
||||
},
|
||||
{
|
||||
"type": "atom",
|
||||
"value": "user_id"
|
||||
}
|
||||
],
|
||||
"name": "unique_user_tweet",
|
||||
"nils_distinct?": true,
|
||||
"where": null
|
||||
}
|
||||
],
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"repo": "Elixir.Mixer.Repo",
|
||||
"schema": null,
|
||||
"table": "tweet_likes"
|
||||
}
|
||||
Reference in New Issue
Block a user