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

Database migration failure #241

Closed
thespad opened this issue Aug 31, 2024 · 2 comments
Closed

Database migration failure #241

thespad opened this issue Aug 31, 2024 · 2 comments

Comments

@thespad
Copy link

thespad commented Aug 31, 2024

Version 0.310.20240830

Opening DB
Connecting to DB
AutoMigrating DB tables

2024/08/31 15:06:01 /build/hishtory/backend/server/internal/database/db.go:62
[6.992ms] [rows:1] SELECT count(*) FROM information_schema.tables WHERE table_schema = CURRENT_SCHEMA() AND table_name = 'enc_history_entries' AND table_type = 'BASE TABLE'

2024/08/31 15:06:01 /build/hishtory/backend/server/internal/database/db.go:62
[0.375ms] [rows:1] SELECT CURRENT_DATABASE()

2024/08/31 15:06:01 /build/hishtory/backend/server/internal/database/db.go:62
[15.200ms] [rows:-] SELECT c.column_name, c.is_nullable = 'YES', c.udt_name, c.character_maximum_length, c.numeric_precision, c.numeric_precision_radix, c.numeric_scale, c.datetime_precision, 8 * typlen, c.column_default, pd.description, c.identity_increment FROM information_schema.columns AS c JOIN pg_type AS pgt ON c.udt_name = pgt.typname LEFT JOIN pg_catalog.pg_description as pd ON pd.objsubid = c.ordinal_position AND pd.objoid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = c.table_name AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = c.table_schema)) where table_catalog = 'hishtory' AND table_schema = CURRENT_SCHEMA() AND table_name = 'enc_history_entries'

2024/08/31 15:06:01 /build/hishtory/backend/server/internal/database/db.go:62 ERROR: could not determine data type of parameter $1 (SQLSTATE 42P18)
[0.422ms] [rows:-] SELECT * FROM "enc_history_entries" LIMIT 1
panic: OpenDB: failed to create underlying DB tables: db.AutoMigrate: ERROR: could not determine data type of parameter $1 (SQLSTATE 42P18)

goroutine 1 [running]:
main.InitDB()
        /build/hishtory/backend/server/server.go:173 +0x273
main.main()
        /build/hishtory/backend/server/server.go:202 +0x9b
@ddworken
Copy link
Owner

ddworken commented Sep 1, 2024

Interesting, thank you for the bug report! I'm looking into this now. Given the source of the error, I think this may be a bug in the underlying gorm library (github.com/go-gorm/gorm) which I did upgrade the version of last week.

ddworken added a commit that referenced this issue Sep 1, 2024
@ddworken
Copy link
Owner

ddworken commented Sep 1, 2024

Ok, it looks like the root cause here is a mismatch of versions where we were using an older version of pgx and the gorm postgres driver, but a newer version of gorm. #243 should fix this, I'm going to let it run through all the tests on GH actions and then will release it ASAP.

I'll also follow up in a separate change to improve our test coverage to ensure we prevent this from happening again in the future.

ddworken added a commit that referenced this issue Sep 7, 2024
* Add test coverage to prevent issues like #241 in the future

* Add debugging

* Fix location of HISHTORY_COMPOSE_TEST var

* Enable tmate for failures

* update

* Re-comment tmate
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

No branches or pull requests

2 participants