You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Upgrade from v1.12.0 to v1.12.1 failed with database migration #6936
I updated my docker image to v1.12.1 and on start the contained failed with. My service is running with OIDC setup.
xiting…
2026-11-04T22:09:05.160Z error: Migration 20260922038700-add-profile-provider.js (up) failed: Original error: type "enum_Users_profileProvider" already exists
2026-11-04T22:09:05.160Z error: Database migration failed.
This can be the result of upgrading from quite old versions and requires manual database intervention.
See https://docs.hedgedoc.org/guides/migration-troubleshooting/ for help.
Switched back to v1.12.0 and service started up fine.
We hit this too (PostgreSQL, Docker). The already exists error is a follow-on
failure. The first start on 1.12.1 fails earlier in the same migration, and
that error is probably already gone from your logs:
Migration 20260922038700-add-profile-provider.js (up) failed: Original error: Cannot read properties of undefined (reading 'toString')
The cause is queryInterface.changeColumn('Users', 'profileid', { unique: false }):
with no type, Sequelize 5.22.5 throws while building the SQL. On PostgreSQL the addColumn before it has already committed the enum type and the column, but
the migration isn't recorded in SequelizeMeta. Every later start then fails on CREATE TYPE, before the catch gets to check for an existing column.
Reproduced with the stock images and default settings, upgrading a fresh 1.12.0
database:
Database
1.12.0 → 1.12.1
SQLite
works
MariaDB 11
fails on every start with the toString error
PostgreSQL 16
toString error first, then type "enum_Users_profileProvider" already exists on every start after
docker network create hd
docker run -d --rm --name hd-db --network hd -e POSTGRES_PASSWORD=pw -e POSTGRES_USER=hd -e POSTGRES_DB=hd postgres:16
E="-e CMD_DB_URL=postgres://hd:pw@hd-db:5432/hd -e CMD_DOMAIN=localhost -e CMD_SESSION_SECRET=x"
docker run -d --name hd-old --network hd $E quay.io/hedgedoc/hedgedoc:1.12.0 # wait for "HTTP Server listening"
docker rm -f hd-old
docker run --rm --network hd $E quay.io/hedgedoc/hedgedoc:1.12.1 # toString error
docker run --rm --network hd $E quay.io/hedgedoc/hedgedoc:1.12.1 # already exists
The test suite runs against in-memory SQLite only (mocha-suite in package.json), which would explain why this wasn't caught. A fix probably
needs both: drop the profileid unique constraint some other way (for example removeConstraint, or changeColumn with type: Sequelize.STRING), and make
the enum creation safe to rerun after a partial failure.
Rolling back to 1.12.0, as you did, is safe: in our reproduction 1.12.0 starts
fine on the half-migrated database.
Workaround on PostgreSQL (tested on the reproduction and on our production
instance): take a dump, check the constraint name with \d "Users", then finish
the migration by hand in one transaction. 1.12.1 then starts and runs the
remaining migrations. We haven't tried this on MariaDB.
BEGIN;
ALTERTABLE"Users" DROP CONSTRAINT"Users_profileid_key";
CREATEINDEXuser_profile_provider_indexON"Users" ("profileProvider");
CREATEUNIQUE INDEXuser_profile_id_profile_provider_indexON"Users" (profileid, "profileProvider");
UPDATE"Users"SET"profileProvider"='email'WHERE email IS NOT NULLAND password IS NOT NULL;
INSERT INTO"SequelizeMeta" (name) VALUES ('20260922038700-add-profile-provider.js');
COMMIT;
One more thing to check first: the next migration, 20261001120000-user-email-unique.js (#6882), fails with Validation error if
two local accounts share an email address, which the race in #6875 could
create. We had one such pair, created 50 ms apart. To find them:
SELECT email, count(*) FROM"Users"WHERE email IS NOT NULLGROUP BY email HAVINGcount(*) >1;
We kept the account that owned notes and set email = NULL on the unused one,
inside the same transaction before the UPDATE ... 'email' line.
Also updating to 1.12.1 and then to 1.12.2 still failes on the enum_Users_profileProvider, the migration is not cancelled/rolled back and would still need manual intervention. Just rolled back to 1.12.0.
Edit (more info):
We're using OIDC in a Docker (quay.io/hedgedoc/hedgedoc:latest) in default Postgres setup.
Activity
ramereth commentedon Nov 4, 2026
We hit this too (PostgreSQL, Docker). The
already existserror is a follow-onfailure. The first start on 1.12.1 fails earlier in the same migration, and
that error is probably already gone from your logs:
The cause is
queryInterface.changeColumn('Users', 'profileid', { unique: false }):with no
type, Sequelize 5.22.5 throws while building the SQL. On PostgreSQL theaddColumnbefore it has already committed the enum type and the column, butthe migration isn't recorded in
SequelizeMeta. Every later start then fails onCREATE TYPE, before thecatchgets to check for an existing column.Reproduced with the stock images and default settings, upgrading a fresh 1.12.0
database:
toStringerrortoStringerror first, thentype "enum_Users_profileProvider" already existson every start afterThe test suite runs against in-memory SQLite only (
mocha-suiteinpackage.json), which would explain why this wasn't caught. A fix probablyneeds both: drop the
profileidunique constraint some other way (for exampleremoveConstraint, orchangeColumnwithtype: Sequelize.STRING), and makethe enum creation safe to rerun after a partial failure.
Rolling back to 1.12.0, as you did, is safe: in our reproduction 1.12.0 starts
fine on the half-migrated database.
Workaround on PostgreSQL (tested on the reproduction and on our production
instance): take a dump, check the constraint name with
\d "Users", then finishthe migration by hand in one transaction. 1.12.1 then starts and runs the
remaining migrations. We haven't tried this on MariaDB.
One more thing to check first: the next migration,
20261001120000-user-email-unique.js(#6882), fails withValidation erroriftwo local accounts share an email address, which the race in #6875 could
create. We had one such pair, created 50 ms apart. To find them:
We kept the account that owned notes and set
email = NULLon the unused one,inside the same transaction before the
UPDATE ... 'email'line.soundstorm commentedon Nov 5, 2026
Also updating to 1.12.1 and then to 1.12.2 still failes on the enum_Users_profileProvider, the migration is not cancelled/rolled back and would still need manual intervention. Just rolled back to 1.12.0.
Edit (more info):
We're using OIDC in a Docker (quay.io/hedgedoc/hedgedoc:latest) in default Postgres setup.
Only checked after downgrade to 1.12.0: