2026-02-18 21:23:15 +00:00
|
|
|
defmodule Berrypod.Repo.Migrations.CreateProductVariants do
|
2026-01-29 08:32:24 +00:00
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
|
|
def change do
|
|
|
|
|
create table(:product_variants, primary_key: false) do
|
|
|
|
|
add :id, :binary_id, primary_key: true
|
2026-01-31 14:24:58 +00:00
|
|
|
|
|
|
|
|
add :product_id, references(:products, type: :binary_id, on_delete: :delete_all),
|
|
|
|
|
null: false
|
|
|
|
|
|
2026-01-29 08:32:24 +00:00
|
|
|
add :provider_variant_id, :string, null: false
|
|
|
|
|
add :title, :string, null: false
|
|
|
|
|
add :sku, :string
|
|
|
|
|
add :price, :integer, null: false
|
|
|
|
|
add :compare_at_price, :integer
|
|
|
|
|
add :cost, :integer
|
|
|
|
|
add :options, :map, default: %{}
|
|
|
|
|
add :is_enabled, :boolean, default: true, null: false
|
|
|
|
|
add :is_available, :boolean, default: true, null: false
|
|
|
|
|
|
|
|
|
|
timestamps(type: :utc_datetime)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
create unique_index(:product_variants, [:product_id, :provider_variant_id])
|
|
|
|
|
create index(:product_variants, [:product_id])
|
|
|
|
|
create index(:product_variants, [:sku])
|
|
|
|
|
create index(:product_variants, [:is_enabled])
|
|
|
|
|
create index(:product_variants, [:is_available])
|
|
|
|
|
end
|
|
|
|
|
end
|