Customer Data Migration

L3
ModelContextProtocolPostgresChinook

Migrate customer data from acquired company MelodyMart into Chinook database using bulk operations and business logic.

Created by Lingxiao Du
2025-08-12
Data MigrationTransactional Operations

Model Ranking

Click on the dots to view the trajectory of each task run
Model
Run Results
Pass@4
Pass^4
Avg Time
Avg Turns
Input Tokens
Output Tokens
Total Tokens
Claude
claude-sonnet-4-high
4
/4
356.0s
16.3
410,583
18,121
428,704
Claude
claude-sonnet-4-low
4
/4
432.9s
16.5
413,306
22,402
435,708
OpenAI
gpt-5-high
4
/4
760.6s
10.3
167,926
23,243
191,169
OpenAI
gpt-5-low
4
/4
218.9s
7.5
106,355
16,374
122,729
OpenAI
gpt-5-medium
4
/4
223.9s
7.5
115,199
16,150
131,349
Grok
grok-4
4
/4
612.6s
7.8
137,219
21,951
159,171
Qwen
qwen-3-coder-plus
4
/4
481.3s
20.5
564,047
29,132
593,179
Claude
claude-sonnet-4
3
/4
574.7s
18.8
451,851
24,565
476,416
OpenAI
gpt-5-mini-high
2
/4
255.5s
7.8
120,102
33,010
153,112
MoonshotAI
kimi-k2-0905
2
/4
911.6s
30.8
668,365
14,744
683,109
Gemini
gemini-2-5-flash
1
/4
97.5s
3.5
73,704
23,659
97,363
Gemini
gemini-2-5-pro
1
/4
288.4s
6.3
161,968
36,060
198,028
OpenAI
gpt-4-1-mini
1
/4
140.7s
13.0
210,668
7,669
218,337
OpenAI
gpt-5-mini-low
1
/4
115.6s
5.3
82,731
13,338
96,069
OpenAI
gpt-5-mini-medium
1
/4
191.8s
7.5
170,160
24,645
194,804
Claude
claude-opus-4-1
0
/1
--
1022.3s
19.0
386,018
18,977
404,995
DeepSeek
deepseek-chat
0
/4
215.5s
5.0
61,170
4,233
65,402
Z.ai
glm-4-5
0
/4
97.2s
5.3
62,195
3,367
65,562
OpenAI
gpt-4-1
0
/4
18.7s
3.5
37,793
501
38,294
OpenAI
gpt-4-1-nano
0
/4
197.3s
11.8
318,376
23,589
341,965
OpenAI
gpt-5-nano-high
0
/4
235.3s
5.3
63,139
41,832
104,971
OpenAI
gpt-5-nano-low
0
/4
35.6s
1.0
10,375
6,891
17,266
OpenAI
gpt-5-nano-medium
0
/4
40.8s
1.3
13,088
7,026
20,113
OpenAI
gpt-oss-120b
0
/4
49.7s
4.3
49,250
3,742
52,992
Grok
grok-code-fast-1
0
/4
64.6s
8.3
134,810
13,097
147,908
MoonshotAI
kimi-k2-0711
0
/4
106.3s
5.3
63,209
3,531
66,740
OpenAI
o3
0
/4
46.5s
3.3
35,181
2,943
38,124
OpenAI
o4-mini
0
/4
42.1s
1.8
18,414
2,920
21,333
Qwen
qwen-3-max
0
/4
1961.6s
18.0
986,997
62,442
1,049,439

Task State

Table "Album" { "AlbumId" int4 [pk, not null] "Title" varchar(160) [not null] "ArtistId" int4 [not null] Indexes { ArtistId [type: btree, name: "IFK_AlbumArtistId"] } } Table "Artist" { "ArtistId" int4 [pk, not null] "Name" varchar(120) } Table "Customer" { "CustomerId" int4 [pk, not null] "FirstName" varchar(40) [not null] "LastName" varchar(20) [not null] "Company" varchar(80) "Address" varchar(70) "City" varchar(40) "State" varchar(40) "Country" varchar(40) "PostalCode" varchar(10) "Phone" varchar(24) "Fax" varchar(24) "Email" varchar(60) [not null] "SupportRepId" int4 Indexes { SupportRepId [type: btree, name: "IFK_CustomerSupportRepId"] } } Table "Employee" { "EmployeeId" int4 [pk, not null] "LastName" varchar(20) [not null] "FirstName" varchar(20) [not null] "Title" varchar(30) "ReportsTo" int4 "BirthDate" timestamp "HireDate" timestamp "Address" varchar(70) "City" varchar(40) "State" varchar(40) "Country" varchar(40) "PostalCode" varchar(10) "Phone" varchar(24) "Fax" varchar(24) "Email" varchar(60) Indexes { ReportsTo [type: btree, name: "IFK_EmployeeReportsTo"] } } Table "Genre" { "GenreId" int4 [pk, not null] "Name" varchar(120) } Table "Invoice" { "InvoiceId" int4 [pk, not null] "CustomerId" int4 [not null] "InvoiceDate" timestamp [not null] "BillingAddress" varchar(70) "BillingCity" varchar(40) "BillingState" varchar(40) "BillingCountry" varchar(40) "BillingPostalCode" varchar(10) "Total" numeric(10,2) [not null] Indexes { CustomerId [type: btree, name: "IFK_InvoiceCustomerId"] } } Table "InvoiceLine" { "InvoiceLineId" int4 [pk, not null] "InvoiceId" int4 [not null] "TrackId" int4 [not null] "UnitPrice" numeric(10,2) [not null] "Quantity" int4 [not null] Indexes { InvoiceId [type: btree, name: "IFK_InvoiceLineInvoiceId"] TrackId [type: btree, name: "IFK_InvoiceLineTrackId"] } } Table "MediaType" { "MediaTypeId" int4 [pk, not null] "Name" varchar(120) } Table "Playlist" { "PlaylistId" int4 [pk, not null] "Name" varchar(120) } Table "PlaylistTrack" { "PlaylistId" int4 [not null] "TrackId" int4 [not null] Indexes { (PlaylistId, TrackId) [type: btree, name: "PK_PlaylistTrack"] TrackId [type: btree, name: "IFK_PlaylistTrackTrackId"] } } Table "Track" { "TrackId" int4 [pk, not null] "Name" varchar(200) [not null] "AlbumId" int4 "MediaTypeId" int4 [not null] "GenreId" int4 "Composer" varchar(220) "Milliseconds" int4 [not null] "Bytes" int4 "UnitPrice" numeric(10,2) [not null] Indexes { AlbumId [type: btree, name: "IFK_TrackAlbumId"] GenreId [type: btree, name: "IFK_TrackGenreId"] MediaTypeId [type: btree, name: "IFK_TrackMediaTypeId"] } } Ref "FK_AlbumArtistId":"Artist"."ArtistId" < "Album"."ArtistId" Ref "FK_CustomerSupportRepId":"Employee"."EmployeeId" < "Customer"."SupportRepId" Ref "FK_EmployeeReportsTo":"Employee"."EmployeeId" < "Employee"."ReportsTo" Ref "FK_InvoiceCustomerId":"Customer"."CustomerId" < "Invoice"."CustomerId" Ref "FK_InvoiceLineInvoiceId":"Invoice"."InvoiceId" < "InvoiceLine"."InvoiceId" Ref "FK_InvoiceLineTrackId":"Track"."TrackId" < "InvoiceLine"."TrackId" Ref "FK_PlaylistTrackPlaylistId":"Playlist"."PlaylistId" < "PlaylistTrack"."PlaylistId" Ref "FK_PlaylistTrackTrackId":"Track"."TrackId" < "PlaylistTrack"."TrackId" Ref "FK_TrackAlbumId":"Album"."AlbumId" < "Track"."AlbumId" Ref "FK_TrackGenreId":"Genre"."GenreId" < "Track"."GenreId" Ref "FK_TrackMediaTypeId":"MediaType"."MediaTypeId" < "Track"."MediaTypeId"

Instruction

Migrate customer data from an acquired company to PostgreSQL using efficient bulk operations.

Your Mission:

Chinook Music Store has recently acquired "MelodyMart," a competing music retailer. Their customer database needs to be migrated into Chinook's PostgreSQL database.

Migration Requirements:

  1. Process all customer records from the data table below and migrate them into the Customer table
  2. Apply business logic during migration:
    • Assign CustomerID values starting from the next available ID
    • Assign all customers to support representative with EmployeeId 3
    • Set Fax field to NULL for all migrated customers
  3. Avoid individual INSERT statements

Customer Data to Migrate:

FirstNameLastNameCompanyAddressCityStateCountryPostalCodePhoneEmail
DanielleJohnsonSanchez-Taylor819 Johnson CourseEast WilliamAKUSA74064386-3794danielle.johnson@sancheztaylor.com
KatherineMoorePeterson-Moore16155 Roman Stream Suite 816New KellystadOKUSA25704103-4131katherine_moore@petersonmoore.org
JoshuaReidMartin-Kelly192 Frank Light Suite 835East LydiamouthMOUSA35594139-5376joshua_reid@martinkelly.org
DouglasTaylorHoffman, Baker and Richards3287 Katelyn Wall Apt. 226South PatrickmouthNCUSA33454801-8451douglast@hoffmanbakerand.net
RyanChavezLiu, Baker and Mason148 Eric TrackNew StephanieNCUSA00575957-0154r.chavez@liubakerandmaso.com
BrianHumphreyMiller Group227 Joseph WellBrandtsideWVUSA96174346-5787brian.humphrey@millergroup.com
JohnBrownChapman and Sons10310 Jones FreewayElizabethboroughNDUSA17843997-3763john.brown@chapmanandsons.com
CollinJordanJenkins-Shields106 Mcbride CovesEast JamesNVUSA18874624-7317collin.jordan@jenkinsshields.com
BrentKiddNovak and Sons7736 Franklin AlleyBakermouthLAUSA55945872-3430brent.kidd@novakandsons.com
JulieBrownWoods, Calhoun and Schmidt121 Emma FreewayWilsonshireIAUSA76381909-1699julieb@woodscalhounand.net
SarahHarrisEdwards, Baker and Anderson5107 Charles Forest Suite 251West JustinNVUSA71701498-0841s.harris@edwardsbakerand.com
JosephPrestonTran, Nelson and Jacobs48740 Cynthia Village Suite 005Lake TinaGAUSA97655786-8011j.preston@trannelsonandja.com
AmyDavenportTran, Jordan and Williams53315 Dickson Summit Apt. 322JohnsonmouthWYUSA54465342-1607a.davenport@tranjordanandwi.com
JamesSellersTorres-Pope03654 Tammy HarborsDarlenefurtTXUSA70783501-4294james.sellers@torrespope.com
DanielHamiltonHartman, Graham and Joyce9340 Smith ValleyWest RyanTNUSA43780951-4846danielh@hartmangrahaman.net
RichardPhillipsLee Ltd299 Sullivan Village Apt. 443FloydmouthNHUSA58406738-7214richardp@leeltd.net
ClarenceCraneChambers and Sons00379 Stanley RoadsLake HeatherNMUSA52884320-1632clarence_crane@chambersandsons.org
BrentWrightBryant Group9868 Merritt Summit Suite 743KatiehavenNMUSA82650347-1434brentw@bryantgroup.net
LuisFernandezHernandez Group316 Rivera MountainBrownchesterMSUSA77057096-7054luis_fernandez@hernandezgroup.org
MelissaAshleyMedina-Navarro3467 Paul SkywayRamseymouthPWUSA17229980-6990melissa.ashley@medinanavarro.com
DawnTaylorWhite-Green75564 King Common Suite 080JeffreylandWIUSA85927003-3092d.taylor@whitegreen.com
DavidCaldwellGould, Marshall and Scott99124 Beth Inlet Suite 631North HeidiMEUSA90188919-0586davidc@gouldmarshallan.net
CaseyHollandAtkinson Group5726 Jessica RunChristinasideWIUSA63873769-4531caseyh@atkinsongroup.net
NicoleSanchezHudson-Barnett75273 Salinas Junctions Suite 948New StacylandIAUSA94882678-3777nicole.sanchez@hudsonbarnett.com
ChristopherWalkerSanchez, Beck and Wood8557 Parker Fort Apt. 351East JavierNJUSA36742989-4134c.walker@sanchezbeckandw.com
MichaelTurnerFerguson, Hill and Mccann271 Audrey Mountains Suite 752West ShelleyfortDEUSA09065671-9022michaelt@fergusonhilland.net
ChristopherWrightDuran, Obrien and Gibbs677 Dalton MeadowAshleytonRIUSA97505133-4123c.wright@duranobrienandg.com
AndreaMooreHayes-Wheeler34471 Sandra Turnpike Apt. 618Lake EdwardKYUSA19144102-4994andrea_moore@hayeswheeler.org
DavidBarkerPowell, Nelson and Fernandez90659 Johnson Forks Apt. 490South AprilNVUSA36959296-7175david_barker@powellnelsonand.org
MathewSantiagoRivera Ltd6807 Leonard Islands Apt. 680GutierrezboroughNCUSA47920977-0348m.santiago@riveraltd.com
SaraKimWashington, Johnson and Mccoy248 Andrea CoursePort RobinNHUSA15897274-8467sara_kim@washingtonjohns.org
JohnArnoldLee-Greene46584 Justin HillsGrimesmouthNDUSA63984558-8675j.arnold@leegreene.com
TinaAllenHall-Rowe7662 Hanna CrossroadMollymouthCTUSA69438702-6217tinaa@hallrowe.net
MatthewSchwartzMiller, Murphy and Craig7809 Jimmy Spur Suite 316Port CynthiavilleNVUSA22306400-5045matthews@millermurphyand.net
RyanSanchezKnight-Sparks19693 Durham DivideSouth DanaNHUSA33967074-8217ryans@knightsparks.net
VanessaEvansVaughn-Bryant67136 Andrews Squares Suite 064New MichelletonPWUSA79983743-9533vanessae@vaughnbryant.net
EricaLeBecker, Taylor and Davis7095 Christopher HillJulieburghIDUSA17823858-8424erica_le@beckertaylorand.org
TammyPhillipsBrock-Mcdonald36851 Smith PlainSouth MiguelviewORUSA50442513-7098tammyp@brockmcdonald.net
RoseWalkerReid Group612 Sophia Hollow Suite 113South ShawnTNUSA97905869-2617rose_walker@reidgroup.org
SheilaRamirezWood, Ramos and Sampson58506 Lopez Crossing Suite 139North KristinburyDCUSA74501318-3933sheilar@woodramosandsam.net
KimKramerSmith, Garrison and Thomas421 David KnollsNew MarioHIUSA35283026-8117kim_kramer@smithgarrisonan.org
KimberlyPalmerHayes and Sons847 Bruce NeckSimmonsvilleNMUSA93876711-5921k.palmer@hayesandsons.com
JoshuaSchultzJoseph, James and Harper8961 Melissa Run Apt. 673MorganmouthMOUSA55025156-5452joshua_schultz@josephjamesandh.org
CarlosDeckerReynolds Ltd80988 Santiago Loop Suite 604MichaelshireNYUSA28385273-1585carlos.decker@reynoldsltd.com
KathrynAndrewsBruce-Villegas402 Park InletMichaelburghVIUSA19277961-2018k.andrews@brucevillegas.com
NicholasChavezWood Ltd910 Eric River Apt. 147TuckermouthMTUSA36305381-5614nicholas_chavez@woodltd.org
AlisonParkerFoster PLC34324 Murphy AvenueBurgessburghDCUSA50335838-8516alison.parker@fosterplc.com
RyanStevensAtkins PLC664 Richard Islands Apt. 975South MeganburyNEUSA77685681-6453ryans@atkinsplc.net
KimberlyJonesWilson, Hicks and Bullock2312 Gonzalez Rapids Apt. 127WebstershireNVUSA89778995-5271kimberly_jones@wilsonhicksandb.org
ScottTurnerVargas-Bell7700 Decker ClubNew BrookefurtNHUSA76565807-9359scott_turner@vargasbell.org
WalterRosarioGarcia-Nolan182 John Mill Suite 889West NathanLAUSA51280659-0515walter.rosario@garcianolan.com
AngelaHughesCummings-Douglas1925 Ponce SquareAndersonlandMEUSA73760652-8168angelah@cummingsdouglas.net
AndrewParkerPeterson Group22141 Ebony WellsNew NicholasGAUSA24204927-0653andrew_parker@petersongroup.org
CherylGoodwinYoung-Allen59774 Shaw Manor Apt. 392BrettfortVIUSA49156818-1412cherylg@youngallen.net
ShannonPalmerDavis-Lozano0606 Young Common Suite 305Port JennifermouthWYUSA19643204-7277shannon.palmer@davislozano.com
RebeccaSmithConley PLC43410 Robert Underpass Suite 117Lake ZacharyburyVTUSA19319460-9539rebecca_smith@conleyplc.org
JacobBarnettVillegas, Jones and Fox7065 Burgess KnollsWest JohnvilleWIUSA76772520-5852jacob_barnett@villegasjonesan.org
TinaMendozaCain Inc43030 Mahoney Passage Suite 874Port DeborahportMIUSA06766541-5667tina_mendoza@caininc.org
MatthewLopezJimenez, Glass and Stone616 Amy IslandsNorth MarkportMEUSA58948962-7570matthewl@jimenezglassand.net
ChristinaGrahamWhitney, Gould and Jones8202 Johnson Cliff Apt. 556New EricmouthMNUSA49261719-2856christinag@whitneygouldand.net
DebraWrightJohnson and Sons681 Hampton Squares Suite 394GonzalezbergPRUSA10207727-1551debraw@johnsonandsons.net
PatriciaYorkMckinney, Graves and Thompson313 Joel Park Apt. 589TannersideDCUSA80710114-6786patricia_york@mckinneygravesa.org
MadelineJonesDay-Cole89226 Marie Path Apt. 422SarahburyMIUSA68513414-3842madelinej@daycole.net
ChristinaDavisJackson, David and Moore001 Stacy Trail Suite 396South PamelasideLAUSA84637473-6471christina.davis@jacksondavidand.com
EricPerryHarris-Lawson556 Kathleen Passage Apt. 537West ShannonbergCTUSA07133469-6325ericp@harrislawson.net
JamesMooreOwens, Koch and Jimenez8733 Williams HavenHarperfortLAUSA70846016-2456jamesm@owenskochandjim.net
BrandonWilliamsLee, Tran and Jones499 David Court Suite 558KariboroughPAUSA67232680-0025brandon_williams@leetranandjones.org
AprilHernandezTaylor, Velazquez and Flores495 Erickson Hills Suite 055South BrandytownPAUSA62706499-3097a.hernandez@taylorvelazquez.com
AlexandriaGriffithHernandez-Becker130 Edwards DriveVaughnchesterNYUSA80648702-8385alexandria_griffith@hernandezbecker.org
AliciaEdwardsStevens PLC549 Lee Gateway Suite 843KellieboroughUTUSA92905757-5844alicia.edwards@stevensplc.com
AshleyDanielsCardenas-Blevins0415 Douglas SummitLewissideKYUSA74165421-9933ashley.daniels@cardenasblevins.com
ElizabethSchmidtHall, Garcia and Rivera20826 Woods Flats Suite 540Lake AudreysideWAUSA95281026-2067e.schmidt@hallgarciaandri.com
SharonHaydenMcdowell-Smith4788 Small DaleNelsonvilleMAUSA21799742-0549s.hayden@mcdowellsmith.com
GregoryChaseWilcox-Robertson1227 Boyle AvenuePatrickmouthWVUSA35496549-9045g.chase@wilcoxrobertson.com
BryanWilsonMoore-Parks145 Jeffrey Dale Suite 279RobertsidePWUSA62213833-9187bryanw@mooreparks.net
ChristianElliottPoole PLC822 Bond MillsLake JamieshireNMUSA12420870-7286christian_elliott@pooleplc.org
AnneHansenRoman, Cummings and Foster391 Rodney SquaresNew VirginialandNJUSA04660462-2656anne_hansen@romancummingsan.org
MollyKnoxMiller-Brandt512 Rice StreamPort AdamAKUSA39608786-8633molly_knox@millerbrandt.org
MichaelHillCannon, Johnson and Keller31190 Harper SquaresEast JoyfurtNVUSA31216830-2843michaelh@cannonjohnsonan.net
BarbaraBartonYoung-Walter4408 Connie MeadowWilliamsstadSDUSA88495685-6624barbara_barton@youngwalter.org
IvanMedinaAtkinson LLC0866 Paul GlensWest DeborahNVUSA49138183-0469ivan.medina@atkinsonllc.com
MorganLopezRamsey, Hansen and Mendoza0331 Rocha Square Apt. 638KimberlyfurtNHUSA70447544-5877morgan.lopez@ramseyhansenand.com
LeahBowenRocha-Wood93204 Phillips Flat Suite 369South AndreaTXUSA44746477-7252l.bowen@rochawood.com
JenniferFreemanMooney, Bernard and Warren006 Megan FortLake EdwardboroughNYUSA60271509-9770jennifer.freeman@mooneybernardan.com
AmandaJenkinsMoreno LLC86211 John River Suite 546West SusanmouthOKUSA32378341-0166amanda_jenkins@morenollc.org
AngelaBrownWarner Inc5918 Jerry Ways Suite 401RachelshireTNUSA04813250-3926angela.brown@warnerinc.com
KevinElliottDavenport, Price and Mosley2185 Connor Fort Apt. 599NovakmouthAKUSA83616477-3586kevin_elliott@davenportpricea.org
JacobWillisMiller-Montgomery114 Norman TunnelLake PeterMNUSA14466104-7541j.willis@millermontgomer.com
ChristopherJordanPeters, Russell and Johnson199 Shields Bridge Suite 661New AdrianaTXUSA50404224-4472christopher.jordan@petersrussellan.com
GaryHillWashington-Jones79937 Derek Avenue Suite 596ScottchesterGUUSA85833924-5937garyh@washingtonjones.net
GregorySandersCarter-Neal356 Velasquez Lock Suite 193Lake KatrinaAKUSA95818737-4167g.sanders@carterneal.com
CynthiaAllenMoore, Henderson and Bennett796 Stephens Turnpike Suite 891Port JohnstadGAUSA85304909-6561cynthia.allen@moorehendersona.com
CoreyWalkerStone, Carpenter and Johnston6798 Michael Burg Suite 146North MariebergMIUSA41381573-8757corey.walker@stonecarpentera.com
SamuelHortonJones-Williams51238 Andrea IsleMullenburyASUSA53591226-6093samuel_horton@joneswilliams.org
BrittanyPriceLewis, Ramirez and Padilla182 Nguyen MountWest EmilyfortNCUSA84270596-9691brittanyp@lewisramirezand.net
MichaelEllisCervantes Ltd912 Wilson Inlet Apt. 252BarnesbergOKUSA50794627-8282michael_ellis@cervantesltd.org
KeithLopezHarvey-Glenn2368 Ortiz OverpassMckinneymouthNMUSA22423190-3404k.lopez@harveyglenn.com
AmandaJacksonCunningham-Barton819 Joseph Plains Suite 807South CurtisMPUSA86179340-7451amanda_jackson@cunninghambarto.org
MichelleWilsonClark Ltd962 Kristen Via Apt. 095CandiceburghMDUSA92782449-4812michelle_wilson@clarkltd.org
SamanthaRiddleMartinez, Cline and Wright67294 Brooks Club Apt. 684ShawnfortMDUSA76779017-5186s.riddle@martinezclinean.com
TammySummersAdams-Clayton929 Kramer Springs Apt. 017North SarahburghNVUSA60337063-2424tammy.summers@adamsclayton.com
DiamondWrightBeck-Banks4361 Aaron NeckEast BrittneyhavenTXUSA58836005-1627diamond.wright@beckbanks.com
JeremyDavisGarcia LLC62218 Chelsey Expressway Suite 532JensenmouthVIUSA28975112-1965jeremy_davis@garciallc.org
LeonardTaylorNewman-Wright043 Julie Hill Apt. 376East VictorlandNCUSA02082552-6965l.taylor@newmanwright.com
KathrynBestSmith Inc3006 Fuller ParkwayHendersonfurtCOUSA84457889-2414kathryn.best@smithinc.com
WilliamHarrisHerrera Group6303 Sandy CrescentSalazartonMEUSA87805210-2027williamh@herreragroup.net
AlexandraLoganGreen, Watson and Brady105 Nelson Circles Suite 917DixontonNMUSA74803252-4191a.logan@greenwatsonandb.com
JoyceSmithSanchez Group2208 Walker Gateway Suite 541DavidtonHIUSA29754806-1744joyces@sanchezgroup.net
ChristopherBryantGonzalez-Elliott937 Vargas Park Apt. 832South AndrewsideMIUSA83855050-6413c.bryant@gonzalezelliott.com
RobertWoodwardDawson Inc86571 William RouteJonesshireARUSA57515234-4565robertw@dawsoninc.net
ShawnHallTaylor PLC12775 Martinez KnollsSouth KyleKSUSA16218124-9035s.hall@taylorplc.com
ChristopherWrightFoster-Williams2067 Cody Cove Apt. 100East JamesMOUSA49291199-4101c.wright@fosterwilliams.com
RachelRamosDavis LLC70296 Crawford LightThompsonboroughPWUSA25031447-2099r.ramos@davisllc.com
DeborahPorterMendoza, Miller and Reyes83806 Castillo Tunnel Suite 598PaulburghAKUSA42296930-4078deborahp@mendozamilleran.net
KatieKeyGarcia Ltd8039 Kelly VillagesEast JoelMDUSA97245590-5992k.key@garcialtd.com
MaryCochranWeaver-Thompson03930 Smith RidgesPort DavidVTUSA23761500-2921maryc@weaverthompson.net
SusanBrooksFoster, Garcia and Turner67528 Walker RadialSouth KurtUTUSA39103220-9690s.brooks@fostergarciaand.com
CarrieMccallWalker, Cunningham and Zuniga1355 Daisy CornersSeanviewILUSA33208154-1006carrie_mccall@walkercunningha.org
JessicaCostaSnyder-Gray79327 Lauren Bypass Suite 054North MatthewfurtGAUSA96443181-5997jessica.costa@snydergray.com
RyanValdezPreston, Moore and Garcia68844 Young CausewayArmstrongfortFLUSA07645506-1497r.valdez@prestonmooreand.com
CollinClarkCarter, Miller and Anthony7741 Lopez Light Suite 270ScottviewINUSA35701902-1158collin_clark@cartermillerand.org
TaraLawrenceBrown, Hughes and Mills374 Ralph Walk Apt. 898North StacyNVUSA23160233-2061tara_lawrence@brownhughesandm.org
JamesCarsonFlowers LLC116 Arnold Walks Suite 870RodriguezbergFLUSA74765991-1914jamesc@flowersllc.net
NatalieBakerWashington, Lynch and Johnson2996 Randy Isle Apt. 074AndrewportMEUSA37246713-2475natalieb@washingtonlynch.net
JessicaJacobsLopez and Sons785 Zachary Estate Apt. 486Port MelissaFMUSA75038023-3030jessica_jacobs@lopezandsons.org
BrentWardHill Group103 Burns Mission Apt. 798MaxviewWAUSA90790140-6029b.ward@hillgroup.com
MercedesHollandClark, Pearson and Palmer2290 Johnny ValleyJenniferviewNEUSA49846574-3748mercedes_holland@clarkpearsonand.org
BreannaSmithLevy, Franco and Hoffman1715 Davidson Wall Suite 443New KathyMHUSA07942965-2074breannas@levyfrancoandho.net
RebeccaSullivanJohnson, Erickson and Armstrong3875 Bruce VilleWest ConnorDCUSA97614482-5135r.sullivan@johnsonerickson.com
JulieParkerWatson-Richards70999 Thomas Fields Apt. 684BrownbergDCUSA26754569-7252julie.parker@watsonrichards.com
TonyWelchEdwards Inc4329 Tracy TrackEast ChristinachesterMOUSA56734760-0835tony.welch@edwardsinc.com
PatriciaShermanLee, Rhodes and Sims54216 Jackson ViewWest StacymouthVAUSA68696985-6257patricias@leerhodesandsim.net
KarenMartinSmith-Walker09821 Dawson TurnpikeSouth NancyviewWIUSA70589909-0100karen.martin@smithwalker.com
RobertJamesKing, Miles and Harris6184 Robert CoveWest DanielvilleNMUSA26538934-8356robertj@kingmilesandhar.net
EthanKelleyWatts Group00119 Hernandez Course Apt. 143HintonportKSUSA61354012-0455ethan_kelley@wattsgroup.org
JoannaDavisSmith and Sons5794 Nathan JunctionsNorth RichardNHUSA36130676-2120j.davis@smithandsons.com
DalePruittPham-Gregory659 Michelle VillagesSouth SamanthaDEUSA54408701-4508d.pruitt@phamgregory.com
TiffanySantiagoStone-Watts3756 Mary PointNorth DawnburghNYUSA62011721-7535tiffanys@stonewatts.net
BrentWalkerGray, Montoya and Miller717 Stewart Parks Apt. 166New AndrealandWYUSA79695948-8375brentw@graymontoyaandm.net
MarciaVelasquezRivera-Saunders571 Katherine Forges Apt. 554JacquelinetonMHUSA22017726-1493m.velasquez@riverasaunders.com
DavidPhelpsBryant and Sons60917 Barrett Parkways Apt. 708New SavannahshireNJUSA67129292-2169davidp@bryantandsons.net
WilliamCruzMoon, Farmer and Hill7226 Cameron Plaza Suite 833New JenniferTXUSA45759228-8515william_cruz@moonfarmerandhi.org
BrandiBenderButler, Adkins and Skinner0810 Thomas Skyway Apt. 342FrancesbergMPUSA08631438-0571b.bender@butleradkinsand.com
JuliaHoffmanDixon Ltd066 Frye Spur Suite 800JamesmouthMPUSA30064598-9334julia_hoffman@dixonltd.org
GregoryFlemingRivers Ltd0648 Anderson PrairieAdammouthVTUSA20791025-9094gregory_fleming@riversltd.org
KristyPierceBowers LLC81826 Davis ForgesLake MartinMNUSA38980398-7801kristyp@bowersllc.net
SeanConwaySellers, Sanchez and Williams1648 Johnson Path Suite 887WilliamsboroughMDUSA67858112-8801s.conway@sellerssancheza.com
EllenAyalaColeman, Garcia and Medina120 Love Camp Apt. 102AngelashireGUUSA30338466-7665ellen.ayala@colemangarciaan.com
PerryWilsonMay PLC901 Reilly CovesKristinportPAUSA11839476-6072p.wilson@mayplc.com
DerekMyersPhillips, Walters and Evans88210 Ashley Lock Apt. 435South RebeccaPRUSA67682222-3943derek.myers@phillipswalters.com
HowardMarshYork PLC814 John Flat Suite 552North JustinCAUSA25863577-5949h.marsh@yorkplc.com
ArianaDiazBenjamin-Jackson36452 Humphrey Mountain Suite 547East DebbielandMPUSA37281283-4110ariana.diaz@benjaminjackson.com
LisaRileyLewis, Johnson and Green256 Patricia Radial Suite 278South MichaeltownTNUSA31811928-2722l.riley@lewisjohnsonand.com
JillWebbWilliams-Juarez45303 Hughes MotorwayNorth TinamouthCTUSA92741844-9892jill_webb@williamsjuarez.org
DesireeDiazVillanueva, Miller and King655 Sparks RapidsNew NicolemouthGAUSA30646184-3222desireed@villanuevamille.net
CarolynMontoyaHall, Shepherd and Cortez773 Deborah Loop Apt. 302East CrystalAZUSA75509202-4286carolyn.montoya@hallshepherdand.com
NatalieLunaValentine-Robinson2369 Laura View Apt. 984Lake GinaNHUSA78689913-6621natalie.luna@valentinerobins.com
JamesHeathCohen, Serrano and Jacobs9908 Christopher ShoalsNew AmberALUSA89441686-5086j.heath@cohenserranoand.com
ShawnaOlsonBell-Ballard2473 Justin WellsScotttownVTUSA97972098-1806s.olson@bellballard.com
GwendolynStewartRodriguez-Simmons8695 Braun Locks Apt. 688WhitesideOHUSA63908449-5621g.stewart@rodriguezsimmon.com
SeanLyonsGarcia PLC8902 Oconnell Avenue Apt. 279DavisviewINUSA49107190-6698seanl@garciaplc.net
JenniferHarperBowman Group84309 Christina SpringWest JohntownGAUSA11883465-6693jennifer.harper@bowmangroup.com
JillianJonesDunn Ltd4393 Spears Ports Apt. 426New CharlesportMAUSA15837848-9476jillian_jones@dunnltd.org
KaylaToddMaldonado-Mosley1416 Erica ForksRobertstadNCUSA70709043-4165kayla.todd@maldonadomosley.com
AngelaWhiteGomez-Shannon37333 Clark Flats Apt. 952North SamanthafortRIUSA01369807-5957angelaw@gomezshannon.net
TravisJoyceRamirez, Walker and Ray678 Wayne LockSouth TiffanyUTUSA68423750-0369travis.joyce@ramirezwalkeran.com
MarkSalazarLopez-Baker9552 Coleman Manor Suite 564WhitebergOKUSA90417314-3866m.salazar@lopezbaker.com
DustinHaleyKennedy Inc7288 Floyd HillsAnnashireARUSA52720120-3471dustin_haley@kennedyinc.org
JulieGreenCastro-Frederick0615 Barbara Run Apt. 455HamptonmouthFMUSA10778694-7225julie_green@castrofrederick.org
CrystalDuncanMiller LLC5449 Nelson MillsJuliehavenNVUSA54763220-2341c.duncan@millerllc.com
GarrettGarciaZuniga Group68114 Christopher LoafJeromeportNVUSA82615228-2005garrettg@zunigagroup.net
MichelleMcdonaldDonovan, Dunn and Taylor979 Mills RouteReginafortNDUSA30271174-5642michellem@donovandunnandt.net
AlexMillsCooper Group774 Katie UnionCarlatownOHUSA49475368-6632alex_mills@coopergroup.org
MariaWalkerHenderson and Sons8463 Ian Highway Apt. 797JackiefortIDUSA42528020-8021mariaw@hendersonandson.net
JosephEspinozaSmith, Davis and Smith6475 Terry BypassChristopherbergARUSA35432618-7234joseph_espinoza@smithdavisandsm.org
MariaMartinezWright, Wise and Ramos71837 Maldonado InletErictonWAUSA72535814-7435maria.martinez@wrightwiseandra.com
MichelleRobinsonYoung Group24916 Albert Canyon Suite 925East EriclandTXUSA81588500-5281m.robinson@younggroup.com
TonyStewartKramer, Sherman and Trujillo306 Ramsey Glen Apt. 778AmyfortIDUSA74779285-5749t.stewart@kramershermanan.com
CaseyMooreWeiss-Weaver86209 Parsons Garden Suite 186New FeliciaWIUSA72782294-5651casey.moore@weissweaver.com
AlexandraJonesWhite Inc73109 Barrett PineBrandonburyPAUSA94590103-7170alexandraj@whiteinc.net
AngelaHurleyShort-Bauer480 Mary ClubNew ColtonVAUSA30780863-3839a.hurley@shortbauer.com
AngelaGrantGarcia, Fowler and Howard612 Andrea Parkways Suite 289MahoneymouthOHUSA43054566-5939a.grant@garciafowlerand.com
NicholasPierceKing, Nixon and West04908 Victoria Hollow Apt. 433AndrewviewPWUSA73070889-9210nicholas_pierce@kingnixonandwes.org
MichaelTaylorPreston-Wright1969 Jessica Stream Suite 727New DawntonVAUSA76035610-5566michael.taylor@prestonwright.com
MollyPerezAtkinson, Mcfarland and Walters48058 Mark Square Apt. 206MullinsshireNYUSA12308364-6225molly.perez@atkinsonmcfarla.com
ThomasMcgeeRoss, Miller and Shaw78376 Ann StreetEast CharlesWIUSA56870591-1665thomasm@rossmillerandsh.net
JamesCooperJohnson, Torres and Huerta270 James Landing Apt. 110New SaraVIUSA38208051-4770jamesc@johnsontorresan.net
JasonMedinaPayne LLC206 Jonathan Circle Suite 394South DianatownCAUSA51441451-0463jason_medina@paynellc.org
WilliamMckinneyWashington-Harper38780 John PinesMatthewfurtWAUSA21079055-5438williamm@washingtonharpe.net
LisaGarrettZamora-Briggs432 Prince ShoalsNorth JessicaNCUSA89367936-3926lisag@zamorabriggs.net
ReneeMurphyAnderson, Delgado and Carpenter48262 Lonnie PointEast LonniebergVAUSA04365566-4742r.murphy@andersondelgado.com
DanielLopezJensen, Obrien and Salazar05172 Joseph LandingPort PaulNJUSA18525233-0604daniel_lopez@jensenobrienand.org
JeffreyPowersTodd Inc9757 Ronald TrailNew JillfurtVAUSA41513699-9880jeffrey.powers@toddinc.com
ShannonWilcoxRich and Sons086 James Mill Suite 447South KellyPWUSA07650827-7181s.wilcox@richandsons.com
KimberlyPacePayne, Long and Morris79371 Nguyen RunLake JessicaCOUSA15464751-8689k.pace@paynelongandmor.com
NicholasJamesBarr PLC22064 Cross MissionCourtneyvilleMHUSA17746309-4077nicholas_james@barrplc.org
AmySmithYoung-Chapman6719 John Plaza Suite 983East EddiestadAZUSA19555099-4510amy.smith@youngchapman.com
RobertThompsonMitchell, Guerrero and Graves9501 Morris LightPort RonaldsideCAUSA38883721-4586r.thompson@mitchellguerrer.com
HeatherSalazarDuncan Ltd9469 Green PortsSarashireNMUSA68619772-9343heather.salazar@duncanltd.com
DavidMarshallMclaughlin and Sons0558 Alex Flats Suite 414WilliammouthWIUSA01304155-6990d.marshall@mclaughlinandso.com


Verify

*.py
Python
"""
Verification script for PostgreSQL Task 2: Customer Data Migration
"""

import os
import sys
import psycopg2
import pickle

def get_connection_params() -> dict:
    """Get database connection parameters."""
    return {
        "host": os.getenv("POSTGRES_HOST", "localhost"),
        "port": int(os.getenv("POSTGRES_PORT", 5432)),
        "database": os.getenv("POSTGRES_DATABASE"),
        "user": os.getenv("POSTGRES_USERNAME"),
        "password": os.getenv("POSTGRES_PASSWORD")
    }

def load_expected_customers():
    """Load the expected customer data from pickle file."""
    import os
    script_dir = os.path.dirname(os.path.abspath(__file__))
    pkl_path = os.path.join(script_dir, 'customer_data.pkl')
    
    try:
        with open(pkl_path, 'rb') as f:
            return pickle.load(f)
    except FileNotFoundError:
        print(f"❌ customer_data.pkl not found at {pkl_path}. Please generate customer data first.")
        return None
    except Exception as e:
        print(f"❌ Error loading customer data: {e}")
        return None

def verify_migrated_customers(conn, expected_customers) -> bool:
    """Verify migrated customers by comparing with expected data as sets."""
    with conn.cursor() as cur:
        # Get all customers with ID > 59 (the migrated ones)
        cur.execute('''
            SELECT "FirstName", "LastName", "Company", "Address", "City", 
                   "State", "Country", "PostalCode", "Phone", "Email", 
                   "SupportRepId", "Fax"
            FROM "Customer" 
            WHERE "CustomerId" > 59
        ''')
        
        actual_customers = cur.fetchall()
        
        if len(actual_customers) != len(expected_customers):
            print(f"❌ Expected {len(expected_customers)} migrated customers, found {len(actual_customers)}")
            return False
        
        # Convert expected customers to tuples for set comparison
        expected_tuples = set()
        for expected in expected_customers:
            expected_tuple = (
                expected['FirstName'], expected['LastName'], expected['Company'],
                expected['Address'], expected['City'], expected['State'],
                expected['Country'], expected['PostalCode'], expected['Phone'], 
                expected['Email'], 3, None  # SupportRepId=3, Fax=None
            )
            expected_tuples.add(expected_tuple)
        
        # Convert actual customers to set with proper type conversion
        actual_tuples = set()
        for row in actual_customers:
            # Convert all fields to strings for consistent comparison
            actual_tuple = (
                str(row[0]) if row[0] is not None else '',  # FirstName
                str(row[1]) if row[1] is not None else '',  # LastName  
                str(row[2]) if row[2] is not None else '',  # Company
                str(row[3]) if row[3] is not None else '',  # Address
                str(row[4]) if row[4] is not None else '',  # City
                str(row[5]) if row[5] is not None else '',  # State
                str(row[6]) if row[6] is not None else '',  # Country
                str(row[7]) if row[7] is not None else '',  # PostalCode
                str(row[8]) if row[8] is not None else '',  # Phone
                str(row[9]) if row[9] is not None else '',  # Email
                int(row[10]) if row[10] is not None else None,  # SupportRepId
                row[11]  # Fax (should be None)
            )
            actual_tuples.add(actual_tuple)
        
        # Check if sets are equal
        if actual_tuples != expected_tuples:
            missing_in_actual = expected_tuples - actual_tuples
            extra_in_actual = actual_tuples - expected_tuples
            
            print(f"❌ Customer data sets don't match!")
            if missing_in_actual:
                print(f"   Missing {len(missing_in_actual)} expected customers")
                for missing in list(missing_in_actual)[:3]:  # Show first 3
                    print(f"   Missing: {missing[0]} {missing[1]} - {missing[2]}")
                if len(missing_in_actual) > 3:
                    print(f"   ... and {len(missing_in_actual) - 3} more")
            
            if extra_in_actual:
                print(f"   Found {len(extra_in_actual)} unexpected customers")
                for extra in list(extra_in_actual)[:3]:  # Show first 3
                    print(f"   Extra: {extra[0]} {extra[1]} - {extra[2]}")
                if len(extra_in_actual) > 3:
                    print(f"   ... and {len(extra_in_actual) - 3} more")
            
            return False
        
        print(f"✅ All {len(expected_customers)} customers migrated correctly")
        print(f"✅ All customers assigned to SupportRepId 3")
        print(f"✅ All customers have Fax field set to NULL")
        print(f"✅ Customer data sets match exactly (order-independent)")
        
        return True

def main():
    """Main verification function."""
    print("=" * 60)
    print("Verifying Customer Data Migration Task")
    print("=" * 60)

    # Load expected customer data
    expected_customers = load_expected_customers()
    if not expected_customers:
        sys.exit(1)
    
    print(f"Loaded {len(expected_customers)} expected customer records")

    # Get connection parameters
    conn_params = get_connection_params()

    if not conn_params["database"]:
        print("❌ No database specified")
        sys.exit(1)

    try:
        # Connect to database
        conn = psycopg2.connect(**conn_params)

        # Verify migration
        success = verify_migrated_customers(conn, expected_customers)

        conn.close()

        if success:
            print("\n🎉 Task verification: PASS")
            sys.exit(0)
        else:
            print("\n❌ Task verification: FAIL")
            sys.exit(1)

    except psycopg2.Error as e:
        print(f"❌ Database error: {e}")
        sys.exit(1)
    except Exception as e:
        print(f"❌ Verification error: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()