rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.18k stars 272 forks source link

Response to COPY command is interpreted as error: #146

Open sittim opened 5 years ago

sittim commented 5 years ago

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;

rubenv commented 5 years ago

Queries are split and executed one at a time. Perhaps our query parser does not recognize the copy correctly and only submits it partially?

On Sat, Sep 7, 2019, 13:07 Timofey notifications@github.com wrote:

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;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rubenv/sql-migrate/issues/146?email_source=notifications&email_token=AAAKPGGGENVFOV7YGXXV4KDQIODOXA5CNFSM4IUPWWO2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJ6KC7Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAKPGFZFQ3CXJGVAFDCOS3QIODOXANCNFSM4IUPWWOQ .

sittim commented 5 years ago

@rubenv that makes sense, the copy command does not end with ;