misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform πŸš€
https://misskey-hub.net/
GNU Affero General Public License v3.0
10.04k stars 1.37k forks source link

db migration error from 11.27.0 to 11.27.1 #5252

Closed CGsama closed 5 years ago

CGsama commented 5 years ago

πŸ’‘ Summary

cant success run yarn migrate

πŸ™‚ Expected Behavior

Success

☹️ Actual Behavior

yarn run v1.17.3
$ ts-node ./node_modules/typeorm/cli.js migration:run
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = current_schema() AND "table_name" = 'migrations'
query: SELECT * FROM "migrations" "migrations"
16 migrations are already loaded in the database.
17 migrations were found in the source code.
UsedUsername1563757595828 is the last executed migration. It was executed on Mon Jul 22 2019 01:06:35 GMT+0000 (Coordinated Universal Time).
1 migrations are new migrations that needs to be executed.
query: START TRANSACTION
query: CREATE TYPE "page_visibility_enum" AS ENUM('public', 'followers', 'specified')
query failed: CREATE TYPE "page_visibility_enum" AS ENUM('public', 'followers', 'specified')
error: { error: type "page_visibility_enum" already exists
    at Connection.parseE (/home/misskey/misskey/node_modules/pg/lib/connection.js:602:11)
    at Connection.parseMessage (/home/misskey/misskey/node_modules/pg/lib/connection.js:399:19)
    at Socket.<anonymous> (/home/misskey/misskey/node_modules/pg/lib/connection.js:121:22)
    at Socket.emit (events.js:193:13)
    at Socket.EventEmitter.emit (domain.js:481:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at Socket.Readable.push (_stream_readable.js:231:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:154:17)
  name: 'error',
  length: 100,
  severity: 'ERROR',
  code: '42710',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'typecmds.c',
  line: '1139',
  routine: 'DefineEnum' }
query: ROLLBACK
Error during migration run:
{ QueryFailedError: type "page_visibility_enum" already exists
    at new QueryFailedError (/home/misskey/misskey/src/error/QueryFailedError.ts:9:9)
    at Query.callback (/home/misskey/misskey/src/driver/postgres/PostgresQueryRunner.ts:178:30)
    at Query.handleError (/home/misskey/misskey/node_modules/pg/lib/query.js:142:17)
    at Connection.connectedErrorMessageHandler (/home/misskey/misskey/node_modules/pg/lib/client.js:194:17)
    at Connection.emit (events.js:193:13)
    at Connection.EventEmitter.emit (domain.js:481:20)
    at Socket.<anonymous> (/home/misskey/misskey/node_modules/pg/lib/connection.js:126:12)
    at Socket.emit (events.js:193:13)
    at Socket.EventEmitter.emit (domain.js:481:20)
    at addChunk (_stream_readable.js:295:12)
  message: 'type "page_visibility_enum" already exists',
  name: 'QueryFailedError',
  length: 100,
  severity: 'ERROR',
  code: '42710',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'typecmds.c',
  line: '1139',
  routine: 'DefineEnum',
  query:
   `CREATE TYPE "page_visibility_enum" AS ENUM('public', 'followers', 'specified')`,
  parameters: [] }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

πŸ“Œ Environment

Ubuntu 18.04

u1-liquid commented 5 years ago

Try Execute node built/tools/accept-migration Pages 1556348509290 to resolve this error.

CGsama commented 5 years ago

So there are nothing needs to do with the db but just the script some how goes to execute?

u1-liquid commented 5 years ago

It would be. these changes are already applied on your database, but it wasn't marked as processed on check table by some reasons (e.g created database with old method, typeorm sync, migrated from v10, and other accidents...), so only thing what you need is 'mark it as processed migration'.

CGsama commented 5 years ago

Gotcha thx!