Persist chat history

This commit is contained in:
Claudio Ortolina
2026-03-17 13:50:01 +00:00
parent bcef30eb52
commit 8fd8dde73d
12 changed files with 717 additions and 121 deletions
+32 -5
View File
@@ -1872,11 +1872,6 @@ msgstr ""
msgid "Chat about album"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Clear chat"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Send message"
@@ -2308,3 +2303,35 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "No online store templates found"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "%{count} message"
msgid_plural "%{count} messages"
msgstr[0] ""
msgstr[1] ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Chat history"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Delete chat"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "New chat"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "No previous chats"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Untitled"
msgstr ""
+32 -5
View File
@@ -1872,11 +1872,6 @@ msgstr ""
msgid "Chat about album"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Clear chat"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Send message"
@@ -2308,3 +2303,35 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "No online store templates found"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "%{count} message"
msgid_plural "%{count} messages"
msgstr[0] ""
msgstr[1] ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Chat history"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format, fuzzy
msgid "Delete chat"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "New chat"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "No previous chats"
msgstr ""
#: lib/music_library_web/components/chat.ex
#, elixir-autogen, elixir-format
msgid "Untitled"
msgstr ""
@@ -0,0 +1,34 @@
defmodule MusicLibrary.Repo.Migrations.CreateChats do
use Ecto.Migration
def change do
create table(:chats, primary_key: false) do
add :id, :binary_id, primary_key: true
add :entity, :string, null: false
add :musicbrainz_id, :uuid, null: false
add :topic, :string
timestamps(type: :utc_datetime)
end
# Listing chats for a specific entity
create index(:chats, [:entity, :musicbrainz_id])
# Ordered listing of chats for a specific entity
create index(:chats, [:entity, :musicbrainz_id, :updated_at])
create table(:chat_messages, primary_key: false) do
add :id, :binary_id, primary_key: true
add :role, :string, null: false
add :content, :text, null: false
add :position, :integer, null: false
add :chat_id, references(:chats, type: :binary_id, on_delete: :delete_all), null: false
timestamps(type: :utc_datetime)
end
# Ordered listing of messages within a chat
create index(:chat_messages, [:chat_id, :position])
end
end