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.2 failed with database migration: 20261001120000-user-email-unique.js #6940
This is (supposed to be) a single user setup, using the SQLite backend, with no fancy configuration options changed.
Looking at db/hedgedoc.sqlite, there are actually two users:
the expected one (myself);
another one with a different address, literally testing@example.com, which I didn't create on my own.
In any case, the error message mentioning some “user-email-unique”-related migration seems quite weird.
Steps to reproduce
Start from a functional v1.12.0 installation.
Upgrade to v1.12.2 directly.
Notice the service no longer starts, due to migration-related errors.
Expected behaviour
There should be no migration-related errors.
Logs
Nov 05 01:01:06 md systemd[1]: Started hedgedoc.service - HedgeDoc - The best platform to write and share markdown..
Nov 05 01:01:08 md yarnpkg[122039]: 2026-11-05T00:01:08.817Z warn: Session secret not set. Using random generated one. Please set`sessionSecret`in your config.json file. All users will be logged out.
Nov 05 01:01:09 md yarnpkg[122039]: 2026-11-05T00:01:09.944Z error: Migration 20261001120000-user-email-unique.js (up) failed: Original error: Validation error
Nov 05 01:01:09 md yarnpkg[122039]: 2026-11-05T00:01:09.944Z error: Database migration failed.
Nov 05 01:01:09 md yarnpkg[122039]: This can be the result of upgrading from quite old versions and requires manual database intervention.
Nov 05 01:01:09 md yarnpkg[122039]: See https://docs.hedgedoc.org/guides/migration-troubleshooting/ for help.
Nov 05 01:01:09 md yarnpkg[122039]: Exiting…
Nov 05 01:01:09 md systemd[1]: hedgedoc.service: Main process exited, code=exited, status=1/FAILURE
Config
Your Setup
Host OS: Debian 13
NodeJS version: v20.19.2
HedgeDoc version: v1.12.2
Code upgraded in place by moving from the v1.12.0 tag to the v1.12.2 one.
I just tried this on my mac with node 20.19.2 and a fresh manual install from the website and I'm not able to reproduce this problem. I assume you copied the files from 1.12.2 into your existing HedgeDoc folder?
I can only assume the problem was something to do with some specific config. Could you maybe include some more of your config to help identifier the problem?
I can reproduce the bug.
When I tested this, before the 1.12.2 release, I created a single user account, and with that a single test note using 1.12.0. I then switched to the new release candidate and started it, the migrations went through and everything worked. I didn't test with multiple accounts - this is something we'll do in the future.
A bit more background why this happens:
We had an issue of a race condition where one could set up multiple accounts with the same email address if they were fast enough. We created a fix that included setting the email column in the database to UNIQUE. This resulted in two problems:
As this problem was quite tricky to reproduce and get the timings right, we figured that it might not affect instances in production. As Upgrade from v1.12.0 to v1.12.1 failed with database migration #6936 shows, this does in fact affect instances which now fail due to duplicate UNIQUE entries in their database.
Since MariaDB does not support indexes over TEXT columns, we had to change the type to STRING/VARCHAR. PostgreSQL and SQLite would work well with TEXT and the uniqueness constraint as well, but since we support MariaDB as well, we needed to change this. We used Sequelize's changeColumn method in the migration for this, which apparently rebuilds the complete table. Somehow either Sequelize or SQLite confused now how the uniqueness should be defined which results in the problem that only one user with an email address and one user without an email address may exist, two users are already too much and result in a uniqueness validation.
I can confirm the issue. I just updated my docker based installation from v1.12.0 to v1.12.2 and now I get "forbidden" errors when I try to open any file that belongs to my user.
Activity
DerMolly commentedon Nov 5, 2026
I just tried this on my mac with node 20.19.2 and a fresh manual install from the website and I'm not able to reproduce this problem. I assume you copied the files from 1.12.2 into your existing HedgeDoc folder?
I can only assume the problem was something to do with some specific config. Could you maybe include some more of your config to help identifier the problem?
ErikMichelson commentedon Nov 5, 2026
I can reproduce the bug.
When I tested this, before the 1.12.2 release, I created a single user account, and with that a single test note using 1.12.0. I then switched to the new release candidate and started it, the migrations went through and everything worked. I didn't test with multiple accounts - this is something we'll do in the future.
A bit more background why this happens:
We had an issue of a race condition where one could set up multiple accounts with the same email address if they were fast enough. We created a fix that included setting the
emailcolumn in the database to UNIQUE. This resulted in two problems:changeColumnmethod in the migration for this, which apparently rebuilds the complete table. Somehow either Sequelize or SQLite confused now how the uniqueness should be defined which results in the problem that only one user with an email address and one user without an email address may exist, two users are already too much and result in a uniqueness validation.A fix is created ASAP.
qsodev commentedon Nov 5, 2026
I can confirm the issue. I just updated my docker based installation from v1.12.0 to v1.12.2 and now I get "forbidden" errors when I try to open any file that belongs to my user.