mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-07-19 02:13:17 -05:00
[GH-ISSUE #7133] SQLite→PostgreSQL migration via pgloader: BIGINT/INTEGER type mismatch causes silent login failure for all users #30114
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jp1337 on GitHub (Apr 25, 2026).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/7133
Summary
When migrating from SQLite to PostgreSQL using
pgloader(as recommended in the Vaultwarden wiki), pgloader maps all SQLiteINTEGERcolumns to PostgreSQLBIGINT(8 bytes). However, Vaultwarden's Diesel schema defines these columns asi32, which maps to PostgreSQLINTEGER(4 bytes).This type mismatch causes Diesel to silently crash when deserializing any user row, which means:
/admin/users/overviewreturns a 500 errorThe failure is completely silent at
INFOlog level and extremely difficult to diagnose.Root Cause
pgloaderconverts SQLiteINTEGER→ PostgreSQLBIGINTby default. When Diesel reads aBIGINT(8 bytes) into a Rusti32(4 bytes), it panics internally:This panic causes
find_by_mailto returnNone, which Vaultwarden treats identically to "user not found" — producing the generic "Username or password is incorrect" message.The panic is only visible at
RUST_LOG=debuglevel. At the default log level, logins silently fail for every user.Affected Columns (28 across 11 tables)
All of these are mapped as
i32in Diesel but pgloader creates them asBIGINT:userslogin_verify_count,client_kdf_type,client_kdf_iter,password_iterations,client_kdf_memory,client_kdf_parallelismattachmentsfile_sizeauth_requestsdevice_typeciphersatype,repromptdevicesatypeemergency_accessatype,status,wait_time_dayseventdevice_type,event_typeorg_policiesatypeorganization_api_keyatypesendsaccess_count,atype,max_access_count,password_itertwofactoratype,last_usedtwofactor_duo_ctxexptwofactor_incompletedevice_typeusers_organizationsatype,statusFix
After running
pgloader, apply this SQL to correct the column types:Suggested Fixes (for maintainers)
There are two good approaches:
Option A — Fix the pgloader config in the wiki
Add
CASToverrides to the pgloader command in the migration documentation:This tells pgloader to use
INTEGERinstead ofBIGINTfor all integer columns.Option B — Add a post-migration SQL script
Include the SQL above as a
post-migration.sqlscript in the wiki or repository, to be run immediately afterpgloader.Option C — Make Diesel schema explicit
Add explicit
CASTor migration guards so mismatched types are caught at startup rather than silently failing at query time.Impact
pgloaderfollowing the official wiki instructions will hit thisEnvironment
pgloader sqlite:///data/db.sqlite3 postgresql://...as documented in wiki