defmodule CMDCMemoryPg.Repo.Migrations.CreateCmdcCheckpoints do use Ecto.Migration def change do create table(:cmdc_checkpoints, primary_key: false) do add :session_id, :string, null: false, size: 255 add :checkpoint_id, :string, null: false, size: 64 # snapshot 走 :erlang.term_to_binary(snap, [:compressed]) → bytea # 避开 jsonb 对 atom / Message struct 的序列化痛点 add :snapshot, :binary, null: false add :label, :string, size: 128 add :metadata, :map, null: false, default: %{} add :saved_at, :utc_datetime_usec, null: false end create index(:cmdc_checkpoints, [:session_id]) create index(:cmdc_checkpoints, [:saved_at]) create unique_index(:cmdc_checkpoints, [:session_id, :checkpoint_id]) end end