Skip to content

[Database] "security_keys" already exists #1468

@icarusfactor

Description

@icarusfactor

Describe the bug
When running "npm run start" I get a database error what seems to be related to but not the same issue ER_TABLE_EXISTS #1211 and migration table duplicate security key bug. But the data I have looks nothing like that and has lots more columns and have remove the db and restarted to no avail.

To Reproduce
Steps to reproduce the behavior:

  1. As spacebar user, I run "npm run start"
  2. Then it throws errors while connected to postgresql database.
  3. See error

Expected behavior
This should start the service on port 3001

Console Logs

[System] linux 5.14.0-611.20.1.el9_7.x86_64 x64
[System] AlmaLinux 9.7 (Moss Jungle Cat) (No build ID)
[Process] Running with PID: 291958
[Process] Starting with 1 threads
[Database] Connecting to postgres db
[Database] Applying missing migrations, if any.
Migration "webauthn1675044825710" failed, error: relation "security_keys" already exists
QueryFailedError: relation "security_keys" already exists
at PostgresQueryRunner.query (/var/www/spacebar.userspace.org/server/node_modules/typeorm/driver/src/driver/postgres/PostgresQueryRunner.ts:325:19)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async webauthn1675044825710.up (/var/www/spacebar.userspace.org/server/src/util/migration/postgres/1675044825710-webauthn.ts:25:9)
at async MigrationExecutor.executePendingMigrations (/var/www/spacebar.userspace.org/server/node_modules/typeorm/migration/src/migration/MigrationExecutor.ts:336:17)
at async DataSource.runMigrations (/var/www/spacebar.userspace.org/server/node_modules/typeorm/data-source/src/data-source/DataSource.ts:404:13)
at async initDatabase (/var/www/spacebar.userspace.org/server/src/util/util/Database.ts:136:5)
at async main (/var/www/spacebar.userspace.org/server/src/bundle/Server.ts:61:5) {
query: 'CREATE TABLE "security_keys" ("id" character varying NOT NULL, "user_id" character varying, "key_id" character varying NOT NULL, "public_key" character varying NOT NULL, "counter" integer NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_6e95cdd91779e7cca06d1fff89c" PRIMARY KEY ("id"))',
parameters: undefined,
driverError: error: relation "security_keys" already exists
at /var/www/spacebar.userspace.org/server/node_modules/pg/lib/client.js:545:17
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async PostgresQueryRunner.query (/var/www/spacebar.userspace.org/server/node_modules/typeorm/driver/src/driver/postgres/PostgresQueryRunner.ts:254:25)
at async webauthn1675044825710.up (/var/www/spacebar.userspace.org/server/src/util/migration/postgres/1675044825710-webauthn.ts:25:9)
at async MigrationExecutor.executePendingMigrations (/var/www/spacebar.userspace.org/server/node_modules/typeorm/migration/src/migration/MigrationExecutor.ts:336:17)
at async DataSource.runMigrations (/var/www/spacebar.userspace.org/server/node_modules/typeorm/data-source/src/data-source/DataSource.ts:404:13)
at async initDatabase (/var/www/spacebar.userspace.org/server/src/util/util/Database.ts:136:5)
at async main (/var/www/spacebar.userspace.org/server/src/bundle/Server.ts:61:5) {
length: 107,
severity: 'ERROR',
code: '42P07',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'heap.c',
line: '1150',
routine: 'heap_create_with_catalog'
},
length: 107,
severity: 'ERROR',
code: '42P07',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'heap.c',
line: '1150',
routine: 'heap_create_with_catalog'
}

System Information:

  • OS: Alma Linux
  • Version 9.7
    • Node Version: [e.g Node v18.7.0]
  • Python 3 Version: [e.g Python 3.10.6]

Env and Software info

The number of threads to run Spacebar on.

THREADS=1

The port the server will listen on.

PORT=3001

The database connection string. Defaults to SQLite3 at project root (database.db).

DATABASE="postgres://spacebar_access:PASSWORD@localhost:5432/spacebar"

  • Database: Postgresql 16
  • Thread Count: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs more informationRequires more information before we can start triage or working on the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions