ash.codegen for media
This commit is contained in:
@@ -436,6 +436,7 @@ export async function validateReadTweet(
|
|||||||
|
|
||||||
export type UpdateTweetInput = {
|
export type UpdateTweetInput = {
|
||||||
content?: string;
|
content?: string;
|
||||||
|
likes?: number;
|
||||||
userId?: UUID;
|
userId?: UUID;
|
||||||
state?: "posted" | "drafted";
|
state?: "posted" | "drafted";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ export type UUID = string;
|
|||||||
// tweets Schema
|
// tweets Schema
|
||||||
export type tweetsResourceSchema = {
|
export type tweetsResourceSchema = {
|
||||||
__type: "Resource";
|
__type: "Resource";
|
||||||
__primitiveFields: "id" | "content" | "userId" | "state";
|
__primitiveFields: "id" | "content" | "likes" | "userId" | "state";
|
||||||
id: UUID;
|
id: UUID;
|
||||||
content: string;
|
content: string;
|
||||||
|
likes: number;
|
||||||
userId: UUID;
|
userId: UUID;
|
||||||
state: "posted" | "drafted";
|
state: "posted" | "drafted";
|
||||||
};
|
};
|
||||||
@@ -19,9 +20,10 @@ export type tweetsResourceSchema = {
|
|||||||
|
|
||||||
export type tweetsAttributesOnlySchema = {
|
export type tweetsAttributesOnlySchema = {
|
||||||
__type: "Resource";
|
__type: "Resource";
|
||||||
__primitiveFields: "id" | "content" | "userId" | "state";
|
__primitiveFields: "id" | "content" | "likes" | "userId" | "state";
|
||||||
id: UUID;
|
id: UUID;
|
||||||
content: string;
|
content: string;
|
||||||
|
likes: number;
|
||||||
userId: UUID;
|
userId: UUID;
|
||||||
state: "posted" | "drafted";
|
state: "posted" | "drafted";
|
||||||
};
|
};
|
||||||
@@ -44,6 +46,16 @@ export type tweetsFilterInput = {
|
|||||||
in?: Array<string>;
|
in?: Array<string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
likes?: {
|
||||||
|
eq?: number;
|
||||||
|
notEq?: number;
|
||||||
|
greaterThan?: number;
|
||||||
|
greaterThanOrEqual?: number;
|
||||||
|
lessThan?: number;
|
||||||
|
lessThanOrEqual?: number;
|
||||||
|
in?: Array<number>;
|
||||||
|
};
|
||||||
|
|
||||||
userId?: {
|
userId?: {
|
||||||
eq?: UUID;
|
eq?: UUID;
|
||||||
notEq?: UUID;
|
notEq?: UUID;
|
||||||
@@ -61,11 +73,11 @@ export type tweetsFilterInput = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const tweetsFilterFields = ["id", "content", "userId", "state", "user"] as const;
|
export const tweetsFilterFields = ["id", "content", "likes", "userId", "state", "user", "s3Key"] as const;
|
||||||
export type tweetsFilterField = (typeof tweetsFilterFields)[number];
|
export type tweetsFilterField = (typeof tweetsFilterFields)[number];
|
||||||
|
|
||||||
|
|
||||||
export const tweetsSortFields = ["id", "content", "userId", "state"] as const;
|
export const tweetsSortFields = ["id", "content", "likes", "userId", "state"] as const;
|
||||||
export type tweetsSortField = (typeof tweetsSortFields)[number];
|
export type tweetsSortField = (typeof tweetsSortFields)[number];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
38
priv/repo/migrations/20260330173403_add_posts_media_s3.exs
Normal file
38
priv/repo/migrations/20260330173403_add_posts_media_s3.exs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
defmodule Mixer.Repo.Migrations.AddPostsMediaS3 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
|
||||||
|
alter table(:tweets) do
|
||||||
|
add :likes, :bigint, null: false, default: 0
|
||||||
|
end
|
||||||
|
|
||||||
|
create table(:media, primary_key: false) do
|
||||||
|
add :id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true
|
||||||
|
add :s3_key, :text, null: false
|
||||||
|
|
||||||
|
add :tweet_id,
|
||||||
|
references(:tweets,
|
||||||
|
column: :id,
|
||||||
|
name: "media_tweet_id_fkey",
|
||||||
|
type: :uuid,
|
||||||
|
prefix: "public"
|
||||||
|
), null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
drop constraint(:media, "media_tweet_id_fkey")
|
||||||
|
|
||||||
|
drop table(:media)
|
||||||
|
|
||||||
|
alter table(:tweets) do
|
||||||
|
remove :likes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
75
priv/resource_snapshots/repo/media/20260330173404.json
Normal file
75
priv/resource_snapshots/repo/media/20260330173404.json
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"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": null,
|
||||||
|
"scale": null,
|
||||||
|
"size": null,
|
||||||
|
"source": "s3_key",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": "media_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"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"base_filter": null,
|
||||||
|
"check_constraints": [],
|
||||||
|
"create_table_options": null,
|
||||||
|
"custom_indexes": [],
|
||||||
|
"custom_statements": [],
|
||||||
|
"has_create_action": true,
|
||||||
|
"hash": "D707EF6F25A8BD5E01A333A9C8CBE9AAAF015CFB31BF4F5A4DE4CDA2CD9A4DD8",
|
||||||
|
"identities": [],
|
||||||
|
"multitenancy": {
|
||||||
|
"attribute": null,
|
||||||
|
"global": null,
|
||||||
|
"strategy": null
|
||||||
|
},
|
||||||
|
"repo": "Elixir.Mixer.Repo",
|
||||||
|
"schema": null,
|
||||||
|
"table": "media"
|
||||||
|
}
|
||||||
99
priv/resource_snapshots/repo/tweets/20260330173405.json
Normal file
99
priv/resource_snapshots/repo/tweets/20260330173405.json
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"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": null,
|
||||||
|
"scale": null,
|
||||||
|
"size": null,
|
||||||
|
"source": "content",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_nil?": false,
|
||||||
|
"default": "0",
|
||||||
|
"generated?": false,
|
||||||
|
"precision": null,
|
||||||
|
"primary_key?": false,
|
||||||
|
"references": null,
|
||||||
|
"scale": null,
|
||||||
|
"size": null,
|
||||||
|
"source": "likes",
|
||||||
|
"type": "bigint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": "tweets_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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_nil?": false,
|
||||||
|
"default": "\"drafted\"",
|
||||||
|
"generated?": false,
|
||||||
|
"precision": null,
|
||||||
|
"primary_key?": false,
|
||||||
|
"references": null,
|
||||||
|
"scale": null,
|
||||||
|
"size": null,
|
||||||
|
"source": "state",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"base_filter": null,
|
||||||
|
"check_constraints": [],
|
||||||
|
"create_table_options": null,
|
||||||
|
"custom_indexes": [],
|
||||||
|
"custom_statements": [],
|
||||||
|
"has_create_action": true,
|
||||||
|
"hash": "72C986AFFFB09E7394DC54328AC3F7E47C24599B894E1E65964132E2598AB55C",
|
||||||
|
"identities": [],
|
||||||
|
"multitenancy": {
|
||||||
|
"attribute": null,
|
||||||
|
"global": null,
|
||||||
|
"strategy": null
|
||||||
|
},
|
||||||
|
"repo": "Elixir.Mixer.Repo",
|
||||||
|
"schema": null,
|
||||||
|
"table": "tweets"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user