Removed metadata column from DB, replacing it with filepath columns

This commit is contained in:
Kieran Eglin 2024-02-24 11:55:52 -08:00
parent 4644044bc6
commit 1eeec684d9
No known key found for this signature in database
GPG key ID: 193984967FCF432D
2 changed files with 19 additions and 3 deletions

View file

@ -10,8 +10,12 @@ defmodule Pinchflat.Media.MediaMetadata do
alias Pinchflat.Media.MediaItem
@allowed_fields ~w(metadata_filepath thumbnail_filepath)a
@required_fields ~w(metadata_filepath thumbnail_filepath)a
schema "media_metadata" do
field :client_response, :map
field :metadata_filepath, :string
field :thumbnail_filepath, :string
belongs_to :media_item, MediaItem
@ -21,8 +25,8 @@ defmodule Pinchflat.Media.MediaMetadata do
@doc false
def changeset(media_metadata, attrs) do
media_metadata
|> cast(attrs, [:client_response])
|> validate_required([:client_response])
|> cast(attrs, @allowed_fields)
|> validate_required(@required_fields)
|> unique_constraint([:media_item_id])
end
end

View file

@ -0,0 +1,12 @@
defmodule Pinchflat.Repo.Migrations.AddMetadataFilepathToMediaMetadata do
use Ecto.Migration
def change do
alter table(:media_metadata) do
add :metadata_filepath, :string, null: false
add :thumbnail_filepath, :string, null: false
remove :client_response, :json
end
end
end