feat: add image metadata fields for optimization pipeline
- Add source_width, source_height, variants_status fields to images table - Remove thumbnail_data (now derived to disk cache) - Add Oban tables via Oban.Migration.up(version: 12) - Update Image schema changeset to include new fields Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
dbadd2a376
commit
cefec1aabd
@ -13,7 +13,9 @@ defmodule SimpleshopTheme.Media.Image do
|
||||
field :data, :binary
|
||||
field :is_svg, :boolean, default: false
|
||||
field :svg_content, :string
|
||||
field :thumbnail_data, :binary
|
||||
field :source_width, :integer
|
||||
field :source_height, :integer
|
||||
field :variants_status, :string, default: "pending"
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
@ -23,7 +25,18 @@ defmodule SimpleshopTheme.Media.Image do
|
||||
@doc false
|
||||
def changeset(image, attrs) do
|
||||
image
|
||||
|> cast(attrs, [:image_type, :filename, :content_type, :file_size, :data, :is_svg, :svg_content])
|
||||
|> cast(attrs, [
|
||||
:image_type,
|
||||
:filename,
|
||||
:content_type,
|
||||
:file_size,
|
||||
:data,
|
||||
:is_svg,
|
||||
:svg_content,
|
||||
:source_width,
|
||||
:source_height,
|
||||
:variants_status
|
||||
])
|
||||
|> validate_required([:image_type, :filename, :content_type, :file_size, :data])
|
||||
|> validate_inclusion(:image_type, ~w(logo header product))
|
||||
|> validate_number(:file_size, less_than: @max_file_size)
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
defmodule SimpleshopTheme.Repo.Migrations.AddImageMetadataAndOban do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:images) do
|
||||
add :source_width, :integer
|
||||
add :source_height, :integer
|
||||
add :variants_status, :string, default: "pending"
|
||||
|
||||
remove :thumbnail_data
|
||||
end
|
||||
|
||||
Oban.Migration.up(version: 12)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user