This commit is contained in:
55
priv/repo/migrations/20260310213733_create_car_policies.exs
Normal file
55
priv/repo/migrations/20260310213733_create_car_policies.exs
Normal file
@@ -0,0 +1,55 @@
|
||||
defmodule PolicyService.Repo.Migrations.CreatePolicyApplications do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:policy_applications, primary_key: false) do
|
||||
add :id, :string, primary_key: true
|
||||
add :application_id, :string, null: false
|
||||
add :org_id, :string, null: false
|
||||
add :submitted_by, :string, null: false
|
||||
add :policy_type, :string, null: false # "car" | "life" | "fire"
|
||||
|
||||
# Applicant — full map, shape varies by individual vs corporate
|
||||
add :applicant_info, :map, default: %{}
|
||||
|
||||
# Policy-type-specific details — shape varies by policy_type
|
||||
add :policy_details, :map, default: %{}
|
||||
|
||||
# Providers + quotes
|
||||
add :selected_providers, {:array, :string}, default: []
|
||||
add :quotes, :map, default: %{}
|
||||
|
||||
# Accepted plan
|
||||
add :accepted_quote_id, :string
|
||||
add :accepted_plan_id, :string
|
||||
add :accepted_provider_id, :string
|
||||
add :accepted_by, :string
|
||||
add :accepted_at, :utc_datetime_usec
|
||||
|
||||
# Solicitation
|
||||
add :solicitation_id, :string
|
||||
add :solicitation_s3_key, :string
|
||||
|
||||
# Issued policy
|
||||
add :policy_number, :string
|
||||
add :premium, :decimal
|
||||
add :effective_date, :date
|
||||
add :expiry_date, :date
|
||||
|
||||
# Status + timestamps
|
||||
add :status, :string, null: false
|
||||
add :submitted_at, :utc_datetime_usec
|
||||
add :solicitation_sent_at, :utc_datetime_usec
|
||||
add :issued_at, :utc_datetime_usec
|
||||
|
||||
timestamps(type: :utc_datetime_usec)
|
||||
end
|
||||
|
||||
create index(:policy_applications, [:org_id])
|
||||
create index(:policy_applications, [:policy_type])
|
||||
create index(:policy_applications, [:status])
|
||||
create index(:policy_applications, [:org_id, :status])
|
||||
create index(:policy_applications, [:org_id, :policy_type])
|
||||
create index(:policy_applications, [:org_id, :policy_type, :status])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
defmodule PolicyService.Repo.Migrations.CreateProjectionVersions do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:projection_versions, primary_key: false) do
|
||||
add(:projection_name, :text, primary_key: true)
|
||||
add(:last_seen_event_number, :bigint)
|
||||
|
||||
timestamps(type: :naive_datetime_usec)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user