All checks were successful
Build and Publish / build-release (push) Successful in 1m41s
50 lines
1.6 KiB
Elixir
50 lines
1.6 KiB
Elixir
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
|
|
# "car" | "life" | "fire"
|
|
add :policy_type, :string, null: false
|
|
|
|
# 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_plan_id, :string
|
|
add :accepted_by, :string
|
|
|
|
# Issued policy
|
|
add :provider_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
|