defmodule Berrypod.Repo.Migrations.CreateAbandonedCarts do use Ecto.Migration def change do create table(:abandoned_carts, primary_key: false) do add :id, :binary_id, primary_key: true add :customer_email, :string, null: false add :order_id, references(:orders, type: :binary_id, on_delete: :nilify_all) add :stripe_session_id, :string, null: false add :cart_total, :integer add :expired_at, :utc_datetime, null: false add :emailed_at, :utc_datetime timestamps(type: :utc_datetime) end create unique_index(:abandoned_carts, [:stripe_session_id]) create index(:abandoned_carts, [:customer_email]) create index(:abandoned_carts, [:inserted_at]) create table(:email_suppressions, primary_key: false) do add :id, :binary_id, primary_key: true add :email, :string, null: false add :reason, :string timestamps(type: :utc_datetime) end create unique_index(:email_suppressions, [:email]) end end