add newsletter and email campaigns

Subscribers with double opt-in confirmation, campaign composer with
draft/scheduled/sent lifecycle, admin dashboard with overview stats,
CSV export, and shop signup form wired into page builder blocks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-28 23:25:28 +00:00
parent 8f989d892d
commit ad2e6d1e6d
32 changed files with 2497 additions and 32 deletions

View File

@@ -0,0 +1,39 @@
defmodule Berrypod.Repo.Migrations.CreateNewsletter do
use Ecto.Migration
def change do
create table(:newsletter_subscribers, primary_key: false) do
add :id, :binary_id, primary_key: true
add :email, :string, null: false
add :status, :string, null: false, default: "pending"
add :confirmation_token, :string
add :confirmed_at, :utc_datetime
add :unsubscribed_at, :utc_datetime
add :consent_text, :string
add :source, :string, default: "website"
add :ip_hash, :string
timestamps(type: :utc_datetime)
end
create unique_index(:newsletter_subscribers, [:email])
create index(:newsletter_subscribers, [:status])
create index(:newsletter_subscribers, [:confirmation_token])
create table(:newsletter_campaigns, primary_key: false) do
add :id, :binary_id, primary_key: true
add :subject, :string, null: false
add :body, :text, null: false
add :status, :string, null: false, default: "draft"
add :scheduled_at, :utc_datetime
add :sent_at, :utc_datetime
add :sent_count, :integer, default: 0
add :failed_count, :integer, default: 0
timestamps(type: :utc_datetime)
end
create index(:newsletter_campaigns, [:status])
create index(:newsletter_campaigns, [:scheduled_at])
end
end