My client has given me a list of vehicles for a project. I need to get them into a table I can use, but they're currently in a .cvs file. I've read around and found some info, but nothing that solves my particular problem.
I've generated a model that matches the info in the .cvs file(id, year, make, model, trim), run the migration, and now have the table I need. The issue comes up when I try to use psql COPY. Here's what I've read will work:
copy list_vehicles from '/path/to/list.csv' DELIMITERS ',' CSV;
but it gives me
ERROR: missing data for column "created_at"
Fine, so I try this:
copy list_vehicles (id, year, make, model, trim) from '/path/to/list.csv' DELIMITERS ',' CSV;
and I get back
ERROR: null value in column "created_at" violates not-null constraint
Ok, so then this should work:
copy list_vehicles (id, year, make, model, trim) from '/path/to/list.csv' DELIMITERS ',' WITH NULL AS ' ' CSV FORCE NOT NULL created_at;
nope,
ERROR: FORCE NOT NULL column "created_at" not referenced by COPY
I'm not sure where to go from here. I was thinking of trying to take the created_at column back out for now, then add it in another migration? Any guidance would be much appreciated.
Thanks