Fix PHONE.csv import duplicate constraint error

- Implement upsert logic in import_phone() function
- Check for existing (id, phone) combinations before insert
- Track duplicates within CSV to skip gracefully
- Update existing records instead of failing on duplicates
- Add detailed statistics: inserted, updated, skipped counts
- Align with upsert pattern used in other import functions
- Add documentation in docs/PHONE_IMPORT_FIX.md

Fixes: UNIQUE constraint failed: phone.id, phone.phone error
when re-importing or uploading CSV with duplicate entries
This commit is contained in:
HotSwapp
2025-10-12 21:45:30 -05:00
parent 22e99d27ed
commit 63809d46fb
62 changed files with 500808 additions and 4269 deletions

View File

@@ -0,0 +1,83 @@
Identifier,Query,Response
BEQ_1,"1st Bequest (relationship , full name)?",
BEQ_2,2nd Bequest?,
BEQ_3,3rd Bequest?,
BEQ_S,Special Bequest?,
BRANCH_OF_SERVICE,Military member's branch of service?,
CASE_CODE,Case code assigned by the Court?,40101
CASE_NUMBER,Case number assigned by the Court?,
CH_#,Number of children from this marriage (two)?,
CH_AGE1,Age of first child (5)?,
CH_DOB1,Birthdate of first child (##/##/##)?,
CH_NAME1,Full name of first child?,
CH_RESIDE,Children reside with (Petitioner/Respondent/Both)?,
C_GUARD_1,"Children's first guardian? (relationship, name)",
C_GUARD_2,Children's second guardian?,
C_GUARD_3,Children's third guardian?,
C_GUARD_4,Children's fourth guardian?,
DB_PLAN_NAME,Name of the defined benefit plan?,
DB_VALUATION_DATE,Date used to value DB plan (##/##/##)?,
DC_PLAN_NAME,Name of the defined contribution plan?,
DC_VALUATION_DATE,Date used to value DC plan (##/##/##)?,
DIED_ON,Date subject died (##/##/##)?,
DOLLARS_OF,"Month, year of purchasing power (June, 1999)?",
EIN,Employer identification number?,
FRINGE_PERCENTAGE,Fringe benefit percentage applied to loss?,
FUTURE_EC_LOSS,"Dollars of future earning capacity loss (633,210)?",
FUTURE_FRINGE_LOSS,"Dollar value of future fringe loss (82,554)?",
FUTURE_SERVICE_LOSS,"Dollar value of future service loss (82,554)?",
FUTURE_WAGE_LOSS,"Dollar value of future wage loss (633,210)?",
INJURED_ON,Date of injury (MM/DD/YY)?,
IS_PREGNANT,"Wife is (pregnant, not pregnant)?",
JUDGMENT_DATE,Date of Judgment (##/##/##)?,
MARRIAGE_#,"Marriage is (first, second, etc.)?",
MARRIED_CS,City and state of marriage?,
MARRIED_ON,Date of marriage (##/##/##)?,
MONTHS_WHILE_MARRIED,Months of military service while married?,
PAST_EC_LOSS,"Dollars of past earning capacity loss (45,332)?",
PAST_FRINGE_LOSS,"Dollar value of past fringe loss (16,985)?",
PAST_SERVICE_LOSS,"Dollar value of past service loss (16,985)?",
PAST_WAGE_LOSS,"Dollar value of past wage loss (45,332)?",
PAY_HOUR_#,Hourly rate for services (###.##)?,
PAY_HOUR_TEXT,Hourly rate for services (One Hundred)?,
PAY_MON_#,Minimum monthly payment (###.##)?,
PAY_MON_TEXT,Minimum monthly payment (Fifty)?,
PAY_RET_#,Retainer that is required (###.##)?,
PAY_RET_TEXT,Retainer that is required (Three Hundred)?,
PERCENT_AWARDED,Percent of defined benefit to Alternate Payee?,50.00% (Fifty Percent)
PLAN#,Plan number?,
PLAN_NAME,Full name of the retirement plan?,
POINTS_WHILE_MARRIED,Points accumulated by Reservist while married?,
P_GUARD_1,"1st Personal Guardian? (relationship, full name)",
P_GUARD_2,2nd Personal Guardian?,
P_GUARD_3,3rd Personal Guardian?,
P_GUARD_4,4th Personal Guardian?,
P_REP_1,"1st Personal Rep.? (relationship, full name)",
P_REP_2,2nd Personal Rep.?,
P_REP_3,3rd Personal Rep.?,
P_REP_4,4th Personal Rep.?,
SECTION,Pertinent section of state statutes?,767.255
SEPARATED_ON,Date of separation (##/##/##)?,
SERVICE_WAGE_RATE,Hourly rate used to value lost services (10.00)?,
SUE_FOR_#,Amount suing for (###.##)?,
SUE_FOR_TEXT,Amount suing for (One Thousand Thirty Two)?,
SUE_FOR_YEAR,Suing for services provided in year (####)?,
SUMMONS_FILED,Date summons was filed (##/##/##)?,
SUMMONS_SERVED,Date summons was served (##/##/##)?,
TAX_YEAR,Tax year (####)?,
TOTAL_EC_LOSS,"Dollar value of earning capacity loss (875,244)?",
TOTAL_LOSS,"Dollar value of all losses (875,244)?",
TRIAL_DATE,Date of trial (##/##/##)?,
TRUSTEE_1,"1st Trustee? (relationship, full name)",
TRUSTEE_2,2nd Trustee?,
TRUSTEE_3,3rd Trustee?,
TRUSTEE_4,4th Trustee?,
VEN_CITY,County of venue?,Milwaukee
VEN_CNTY,City of venue?,Milwaukee
VEN_ST,State of venue?,Wisconsin
^ALTP,"Alternate Payee is (1 = client, 2 = other party)?",
^HUS,"Husband is (1 = client, 2 = other party)?",
^PART,"Participant is (1 = client, 2 = other party)?",
^PET,"Petitioner is (1 = client, 2 = other party)?",
^RES,"Respondent is (1 = client, 2 = other party)?",
^WIF,"Wife is (1 = client, 2 = other party)?",
1 Identifier Query Response
2 BEQ_1 1st Bequest (relationship , full name)?
3 BEQ_2 2nd Bequest?
4 BEQ_3 3rd Bequest?
5 BEQ_S Special Bequest?
6 BRANCH_OF_SERVICE Military member's branch of service?
7 CASE_CODE Case code assigned by the Court? 40101
8 CASE_NUMBER Case number assigned by the Court?
9 CH_# Number of children from this marriage (two)?
10 CH_AGE1 Age of first child (5)?
11 CH_DOB1 Birthdate of first child (##/##/##)?
12 CH_NAME1 Full name of first child?
13 CH_RESIDE Children reside with (Petitioner/Respondent/Both)?
14 C_GUARD_1 Children's first guardian? (relationship, name)
15 C_GUARD_2 Children's second guardian?
16 C_GUARD_3 Children's third guardian?
17 C_GUARD_4 Children's fourth guardian?
18 DB_PLAN_NAME Name of the defined benefit plan?
19 DB_VALUATION_DATE Date used to value DB plan (##/##/##)?
20 DC_PLAN_NAME Name of the defined contribution plan?
21 DC_VALUATION_DATE Date used to value DC plan (##/##/##)?
22 DIED_ON Date subject died (##/##/##)?
23 DOLLARS_OF Month, year of purchasing power (June, 1999)?
24 EIN Employer identification number?
25 FRINGE_PERCENTAGE Fringe benefit percentage applied to loss?
26 FUTURE_EC_LOSS Dollars of future earning capacity loss (633,210)?
27 FUTURE_FRINGE_LOSS Dollar value of future fringe loss (82,554)?
28 FUTURE_SERVICE_LOSS Dollar value of future service loss (82,554)?
29 FUTURE_WAGE_LOSS Dollar value of future wage loss (633,210)?
30 INJURED_ON Date of injury (MM/DD/YY)?
31 IS_PREGNANT Wife is (pregnant, not pregnant)?
32 JUDGMENT_DATE Date of Judgment (##/##/##)?
33 MARRIAGE_# Marriage is (first, second, etc.)?
34 MARRIED_CS City and state of marriage?
35 MARRIED_ON Date of marriage (##/##/##)?
36 MONTHS_WHILE_MARRIED Months of military service while married?
37 PAST_EC_LOSS Dollars of past earning capacity loss (45,332)?
38 PAST_FRINGE_LOSS Dollar value of past fringe loss (16,985)?
39 PAST_SERVICE_LOSS Dollar value of past service loss (16,985)?
40 PAST_WAGE_LOSS Dollar value of past wage loss (45,332)?
41 PAY_HOUR_# Hourly rate for services (###.##)?
42 PAY_HOUR_TEXT Hourly rate for services (One Hundred)?
43 PAY_MON_# Minimum monthly payment (###.##)?
44 PAY_MON_TEXT Minimum monthly payment (Fifty)?
45 PAY_RET_# Retainer that is required (###.##)?
46 PAY_RET_TEXT Retainer that is required (Three Hundred)?
47 PERCENT_AWARDED Percent of defined benefit to Alternate Payee? 50.00% (Fifty Percent)
48 PLAN# Plan number?
49 PLAN_NAME Full name of the retirement plan?
50 POINTS_WHILE_MARRIED Points accumulated by Reservist while married?
51 P_GUARD_1 1st Personal Guardian? (relationship, full name)
52 P_GUARD_2 2nd Personal Guardian?
53 P_GUARD_3 3rd Personal Guardian?
54 P_GUARD_4 4th Personal Guardian?
55 P_REP_1 1st Personal Rep.? (relationship, full name)
56 P_REP_2 2nd Personal Rep.?
57 P_REP_3 3rd Personal Rep.?
58 P_REP_4 4th Personal Rep.?
59 SECTION Pertinent section of state statutes? 767.255
60 SEPARATED_ON Date of separation (##/##/##)?
61 SERVICE_WAGE_RATE Hourly rate used to value lost services (10.00)?
62 SUE_FOR_# Amount suing for (###.##)?
63 SUE_FOR_TEXT Amount suing for (One Thousand Thirty Two)?
64 SUE_FOR_YEAR Suing for services provided in year (####)?
65 SUMMONS_FILED Date summons was filed (##/##/##)?
66 SUMMONS_SERVED Date summons was served (##/##/##)?
67 TAX_YEAR Tax year (####)?
68 TOTAL_EC_LOSS Dollar value of earning capacity loss (875,244)?
69 TOTAL_LOSS Dollar value of all losses (875,244)?
70 TRIAL_DATE Date of trial (##/##/##)?
71 TRUSTEE_1 1st Trustee? (relationship, full name)
72 TRUSTEE_2 2nd Trustee?
73 TRUSTEE_3 3rd Trustee?
74 TRUSTEE_4 4th Trustee?
75 VEN_CITY County of venue? Milwaukee
76 VEN_CNTY City of venue? Milwaukee
77 VEN_ST State of venue? Wisconsin
78 ^ALTP Alternate Payee is (1 = client, 2 = other party)?
79 ^HUS Husband is (1 = client, 2 = other party)?
80 ^PART Participant is (1 = client, 2 = other party)?
81 ^PET Petitioner is (1 = client, 2 = other party)?
82 ^RES Respondent is (1 = client, 2 = other party)?
83 ^WIF Wife is (1 = client, 2 = other party)?