Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore error when new column is added to DB schema (allow backward-compatible migrations) #15

Merged
merged 3 commits into from
Jun 3, 2024

Conversation

VojtechVitek
Copy link
Member

@VojtechVitek VojtechVitek commented Jun 3, 2024

Fixes #13 -- Pgkit is not backward-compatible when a new column is added to a DB table schema

@VojtechVitek VojtechVitek changed the title Add extra column to test #13 backward-compatibility WIP: Fix backward-compatibility when new column is added to the DB schema Jun 3, 2024
@@ -2,6 +2,7 @@ CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
disabled BOOLEAN,
new_column_not_in_code BOOLEAN, -- test for backward-compatible migrations, see https://github.com/goware/pgkit/issues/13
Copy link
Member Author

@VojtechVitek VojtechVitek Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to fail with

=== RUN   TestSugarInsertAndSelectRows
    pgkit_test.go:67: 
        	Error Trace:	/home/runner/work/pgkit/pgkit/tests/pgkit_test.go:67
        	Error:      	Received unexpected error:
        	            	pgkit: scanning: scanning: doing scan: scanFn: scany: column: 'new_column_not_in_code': no corresponding field found, or it's unexported in pgkit_test.Account
        	Test:       	TestSugarInsertAndSelectRows
    pgkit_test.go:68: 
        	Error Trace:	/home/runner/work/pgkit/pgkit/tests/pgkit_test.go:68
        	Error:      	"[]" should have 1 item(s), but has 0
        	Test:       	TestSugarInsertAndSelectRows

Fixes this error:
scany: column: 'new_field': no corresponding field found, or it's unexported in data.Collection
@VojtechVitek VojtechVitek changed the title WIP: Fix backward-compatibility when new column is added to the DB schema Fix backward-compatibility when new column is added to the DB schema Jun 3, 2024
@VojtechVitek VojtechVitek changed the title Fix backward-compatibility when new column is added to the DB schema Ignore error when new column is added to DB schema (allow backward-compatible migrations) Jun 3, 2024
@pkieltyka pkieltyka merged commit 8cb5235 into master Jun 3, 2024
1 check passed
@pkieltyka pkieltyka deleted the q8rWXBbt branch June 3, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pgkit is not backward-compatible when a new column is added to a DB table schema
2 participants