Data Migrations and Flat-file Imports (csv, etc)

After seeing @rob demo Data Migrations on yesterday’s meetup, I started to imagine how I might use it in practice.

Say I am adding some reference-type table with a list of options. I’d likely create the model and then load in the data.

If there are a handful or so of records, I’m good with either manually writing individual prisma db in/upserts with the data values – or even maybe iterating some JSON and again doing in/upserts. Little tedious, but hey.

However, for anything a bit longer (list of countries) I might want to load a flat file, because some reference data would be available that way. I’d simply want to specify the file, maybe the columns and/or map to my model.

But - then I wondered am I really migrating – or loading? And if I am loading, I may was well just psql copy a csv file (after I sort out the column names, pick the ones I want, get the order right and make sure I load in dev, staging, and prod when the time comes).

If I were to load csv/flat/json files, I’d want to store those inside the data migration folder and then maybe an equivalent of the prisma schema “steps.json” would specify the file and data mapping.

Would flat-file import be something people would be interested in/useful in data migrations?