8000 Upgrade from v1.12.0 to v1.12.2 failed with database migration: 20261001120000-user-email-unique.js · Issue #6940 · hedgedoc/hedgedoc · GitHub
[go: up one dir, main page]

Skip to content

Upgrade from v1.12.0 to v1.12.2 failed with database migration: 20261001120000-user-email-unique.js #6940

Open

Description

@CyrilBrulebois

Description

(This is not a duplicate of #6936.)

Seeing the double release, I skipped v1.12.1 and went directly from v1.12.0 to v1.12.2. The build part is fine, but the service no longer starts:

error:         Migration 20261001120000-user-email-unique.js (up) failed: Original error: Validation error
error:         Database migration failed.

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

  1. Start from a functional v1.12.0 installation.
  2. Upgrade to v1.12.2 directly.
  3. 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.

Additional context

No response

Activity

  1. DerMolly commented on Nov 5, 2026

    @DerMolly
    Member

    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?

  2. self-assigned this
    on Nov 5, 2026
  3. added this to the Version 1.x milestone on Nov 5, 2026
  4. added theissue type on Nov 5, 2026
  5. ErikMichelson commented on Nov 5, 2026

    @ErikMichelson
    Member

    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:

    1. 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.
    2. 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.

    A fix is created ASAP.

  6. qsodev commented on Nov 5, 2026

    @qsodev

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0