rubenv / rubenv/sql-migrate

Response to COPY command is interpreted as error:

Open
#146 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
Go
Stars
3.4k
Forks
292
PR merge metrics
No merged PRs in 30d

Description

When applying a migration with COPY statement, the following error shows appears:

Migration failed: pq: unknown response for simple query: 'G' handling 20190903062409-test_data.sql

This is isolated COPY command:

COPY public.users (id, name, email, password, confirm_selector, confirm_verifier, confirmed, attempt_count, last_attempt, locked, recover_selector, recover_verifier, recover_token_expiry, o_auth2_u_i_d, o_auth2_provider, o_auth2_access_token, o_auth2_refresh_token, o_auth2_expiry, t_o_t_p_secret_key, s_m_s_phone_number, s_m_s_seed_phone_number, recovery_codes) FROM stdin;
1	username	email@gmail.com	$2a$1mysecrectpasswordEjCc8XddtcAPW			t	0	0001-01-01	0001-01-01			0001-01-01					0001-01-01				
\.

When copy command is executed like so psql -f file_with_above_statement.sql, reply is

COPY 1

So my theory is that the sql-migrate does not recognize the COPY 1 output which is the result of COPY statement and outputs an error;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the migration containing the shown PostgreSQL COPY statement and compare it with psql's COPY 1 response. Trace how sql-migrate handles PostgreSQL migration responses, then add or update coverage for COPY and verify that the migration succeeds without the unknown-response error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.