Failed at the sogebot@11.14.1 prestart script

When updating the bot, I get the following error in the log.

... Migration in progress, please wait (see logs/migration.log for progress and error) ...

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! sogebot@11.14.1 prestart: `node ./tools/mklogdir.js && echo '... Migration in progress, please 
wait (see logs/migration.log for progress and error) ...

npm ERR! ' && typeorm migration:run >logs/migration.log 2>&1`

npm ERR! Exit status 1

npm ERR! Failed at the sogebot@11.14.1 prestart script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR!     /root/.npm/_logs/2020-09-23T14_39_33_063Z-debug.log

That is in the migration.log

query: SELECT * FROM "sqlite_master" WHERE "type" = 'table' AND "name" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
35 migrations are already loaded in the database.
36 migrations were found in the source code.
spotifyBanList1595974777207 is the last executed migration. It was executed on Tue Jul 28 2020 22:19:37 GMT+0000 (Coordinated Universal Time).
1 migrations are new migrations that needs to be executed.
query: BEGIN TRANSACTION
query: CREATE UNIQUE INDEX "IDX_dashboard_userId_createdAt_type" ON "dashboard" ("userId", "createdAt", "type") 
query failed: CREATE UNIQUE INDEX "IDX_dashboard_userId_createdAt_type" ON "dashboard" ("userId", "createdAt", "type") 
error: Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: dashboard.userId, dashboard.createdAt, dashboard.type
--> in Database#all('CREATE UNIQUE INDEX "IDX_dashboard_userId_createdAt_type" ON "dashboard" ("userId", "createdAt", "type") ', undefined, [Function: handler])
    at SqliteQueryRunner.<anonymous> (/app/node_modules/typeorm/driver/sqlite/SqliteQueryRunner.js:64:48)
    at step (/app/node_modules/tslib/tslib.js:139:27)
    at Object.next (/app/node_modules/tslib/tslib.js:120:57)
    at fulfilled (/app/node_modules/tslib/tslib.js:110:62) {
  errno: 19,
  code: 'SQLITE_CONSTRAINT',
  __augmented: true
}
query: ROLLBACK
Error during migration run:
QueryFailedError: SQLITE_CONSTRAINT: UNIQUE constraint failed: dashboard.userId, dashboard.createdAt, dashboard.type
    at new QueryFailedError (/app/node_modules/typeorm/error/QueryFailedError.js:11:28)
    at Statement.handler (/app/node_modules/typeorm/driver/sqlite/SqliteQueryRunner.js:48:38)
    at Statement.replacement (/app/node_modules/sqlite3/lib/trace.js:25:27) {
  errno: 19,
  code: 'SQLITE_CONSTRAINT',
  __augmented: true,
  query: 'CREATE UNIQUE INDEX "IDX_dashboard_userId_createdAt_type" ON "dashboard" ("userId", "createdAt", "type") ',
  parameters: []
}

Yes, this is known issue on discord already discussed

Unfortunately you will need to fix this issue manually. There are two options to do.

  1. UNIX only: You don’t care about dashboards and you can re-do them. Then you run in bot folder npx typeorm query 'DELETE from dashboard' and npx typeorm query 'DELETE from widgets'.
  2. You would need to go to your sqlite/mysql/postgres table and delete duplicated dashboards with same userId, createdAt and type values
  3. If on Windows unzip migration.zip (3.6 KB) to dest/database/

After this, run bot as usual.

This is unfortunatelly cause by duplication bug and I didn’t expect that so many of you would have that. :frowning:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.