goose
goose copied to clipboard
Question: What is the status of postgres COPY FROM STDIN support?
I am trying to capture the migrations performed by Django in a goose migration and so have dumped the relevant tables with data, using a pg_dump execution (I am using postgres, obviously).
Upon migration with goose, the COPY FROM STDIN statements fail initially with a missing semi-colon and if I wrap them in goose statement begin and end directives, like so:
-- +goose StatementBegin
COPY public.django_content_type (id, app_label, model) FROM stdin;
1 admin logentry
2 auth permission
3 auth group
4 auth user
5 contenttypes contenttype
6 sessions session
\.
-- +goose StatementEnd
they then fail with:
2019/01/10 14:28:17 goose run: FAIL pq: syntax error at or near "1", quitting migration
As I understand it from the discussion here, lib/pq does actually support COPY FROM STDIN.
Am I using it incorrectly? Or does goose itself not support this statement?
FWIW: a workaround for my particular use case is to use the --inserts
option of the pg_dump tool so that I don't need to worry about COPY FROM STDIN statements.
+1
@jonseymour @thatguydan mind testing v2.7.0-rc1? It should fix this issue.
I wasn't able to get this to work successfully. I tried both v2.7.0-rc1 and v.2.7.0-rc3.
I see the below is in a test case, so I can't for the life of my figure out why mine is failing.
-- +goose StatementBegin
COPY public.django_content_type (id, app_label, model) FROM stdin;
1 admin logentry
2 auth permission
3 auth group
4 auth user
5 contenttypes contenttype
6 sessions session
\.
-- +goose StatementEnd
$ ./gw.sh up
2019/03/25 14:17:37 goose run: ERROR 00003_initial_data.sql: failed to run SQL migration: failed to execute SQL query "COPY public.django_content_type (id, app_label, model) FROM stdin;\n1\tadmin\tlogentry\n2\tauth\tpermission\n3\tauth\tgroup\n4\tauth\tuser\n5\tcontenttypes\tcontenttype\n6\tsessions\tsession\n\\.\n": pq: syntax error at or near "1"
$ goose -version
v2.7.0-rc1```