diff --git a/assets/js/ash_rpc.ts b/assets/js/ash_rpc.ts index 4b1efd6..34fb399 100644 --- a/assets/js/ash_rpc.ts +++ b/assets/js/ash_rpc.ts @@ -436,6 +436,7 @@ export async function validateReadTweet( export type UpdateTweetInput = { content?: string; + likes?: number; userId?: UUID; state?: "posted" | "drafted"; }; diff --git a/assets/js/ash_types.ts b/assets/js/ash_types.ts index b1d1d4b..c461a0e 100644 --- a/assets/js/ash_types.ts +++ b/assets/js/ash_types.ts @@ -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; }; + likes?: { + eq?: number; + notEq?: number; + greaterThan?: number; + greaterThanOrEqual?: number; + lessThan?: number; + lessThanOrEqual?: number; + in?: Array; + }; + 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]; diff --git a/priv/repo/migrations/20260330173403_add_posts_media_s3.exs b/priv/repo/migrations/20260330173403_add_posts_media_s3.exs new file mode 100644 index 0000000..b40aeb3 --- /dev/null +++ b/priv/repo/migrations/20260330173403_add_posts_media_s3.exs @@ -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 diff --git a/priv/resource_snapshots/repo/media/20260330173404.json b/priv/resource_snapshots/repo/media/20260330173404.json new file mode 100644 index 0000000..47fd600 --- /dev/null +++ b/priv/resource_snapshots/repo/media/20260330173404.json @@ -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" +} \ No newline at end of file diff --git a/priv/resource_snapshots/repo/tweets/20260330173405.json b/priv/resource_snapshots/repo/tweets/20260330173405.json new file mode 100644 index 0000000..e8a9a7c --- /dev/null +++ b/priv/resource_snapshots/repo/tweets/20260330173405.json @@ -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" +} \ No newline at end of file