Reputation: 51
Trying to import a .csv into my postgres table using the following approach:
System: WSL2 - UBUNTU 20.04
psql -d db_name --user=username -c "\copy test_list FROM 'testmngrs.csv' delimiter '|' csv;"
The content format of my .csv:
1,Name,name@store_id.com,1234567891,City Name
The error I'm receiving:
ERROR: invalid input syntax for type bigint:
CONTEXT: COPY test_list, line 1, column id:
The table:
SELECT * FROM test_list;
id | store_id | name | email | phone | city
The additional id at the head of the table above was not something created during my initial set up of the table.
My ecto migration file is as follows:
I'm not sure what's causing the BigInt error, nor how to avoid it as I copy over the data. I'm also a bit confused as to why there's an additional id column in my table given that it was never defined in my migration
I'm pretty new to postgresql and elixir / ecto so any assistance is greatly/guidance/context is greatly appreciated!
Upvotes: 0
Views: 530
Reputation: 23129
From the docs:
By default, the table will also include an
:id
primary key field that has a type of:bigserial.
Ecto assumes you want it to generate the id
field by default. It's better to just go with it. But you can configure it somewhat counter-intuitively by setting primary_key: false
on the table, and primary_key: true
on the column:
create table(:managers, primary_key: false) do
add :store_id, :integer, null: false, primary_key: true
...
Upvotes: 1