ash.codegen for media

This commit is contained in:
2026-03-30 13:34:32 -04:00
parent 63d91043e4
commit 6152dcdeea
5 changed files with 229 additions and 4 deletions

View File

@@ -436,6 +436,7 @@ export async function validateReadTweet(
export type UpdateTweetInput = {
content?: string;
likes?: number;
userId?: UUID;
state?: "posted" | "drafted";
};

View File

@@ -8,9 +8,10 @@ export type UUID = string;
// tweets Schema
export type tweetsResourceSchema = {
__type: "Resource";
__primitiveFields: "id" | "content" | "userId" | "state";
__primitiveFields: "id" | "content" | "likes" | "userId" | "state";
id: UUID;
content: string;
likes: number;
userId: UUID;
state: "posted" | "drafted";
};
@@ -19,9 +20,10 @@ export type tweetsResourceSchema = {
export type tweetsAttributesOnlySchema = {
__type: "Resource";
__primitiveFields: "id" | "content" | "userId" | "state";
__primitiveFields: "id" | "content" | "likes" | "userId" | "state";
id: UUID;
content: string;
likes: number;
userId: UUID;
state: "posted" | "drafted";
};
@@ -44,6 +46,16 @@ export type tweetsFilterInput = {
in?: Array<string>;
};
likes?: {
eq?: number;
notEq?: number;
greaterThan?: number;
greaterThanOrEqual?: number;
lessThan?: number;
lessThanOrEqual?: number;
in?: Array<number>;
};
userId?: {
eq?: 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 const tweetsSortFields = ["id", "content", "userId", "state"] as const;
export const tweetsSortFields = ["id", "content", "likes", "userId", "state"] as const;
export type tweetsSortField = (typeof tweetsSortFields)[number];

View 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

View 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"
}

View 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"
}