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

bun:split at top of migrations results in blank transaction #1114

Open
emoss08 opened this issue Jan 26, 2025 · 0 comments
Open

bun:split at top of migrations results in blank transaction #1114

emoss08 opened this issue Jan 26, 2025 · 0 comments

Comments

@emoss08
Copy link
Contributor

emoss08 commented Jan 26, 2025

Description

Placing --bun:split at the top of migration file causes SQL errors due to blank transaction.

Reproduction

Run: go run cmd/db/main.go db create_tx_sql user

Put --bun:split at the top of the file

Run go run cmd/db/main.go db migrate

Causes the following error to occur.

[bun]  16:29:29.374   COMMIT                1.133ms  COMMIT
[bun]  16:29:29.376   INSERT                1.445ms  INSERT INTO bun_migrations ("id", "name", "group_id", "migrated_at") VALUES (DEFAULT, '20250126210710', 1, DEFAULT) RETURNING "id", "migrated_at"
[bun]  16:29:29.376   BEGIN                   530µs  BEGIN
[bun]  16:29:29.377                           368µs       *errors.errorString: pgdriver: query is empty 
[bun]  16:29:29.377   ROLLBACK                 16µs  ROLLBACK     *errors.errorString: driver: bad connection 
Migration failed: pgdriver: query is empty
[bun]  16:29:29.382   DELETE                5.677ms  DELETE FROM bun_migration_locks WHERE ("table_name" = 'bun_migrations')

Notes

Resolving this is as easy as removing the --bun:split however, it did take me quite a while to figure out this was in the reason the error was being caused. It might be good to omit the bun:split or maybe give the user back an error. Regardless, just wanted to bring this to your attention.

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

1 participant