Skip to content

ER_TABLE_EXISTS #1211

@itsarts1

Description

@itsarts1

Describe the bug
When attempting to start spacebar-server a database error appears pertaining to an already existing table.
I check the DB and I can confirm that the table exists. My question is why is it attempting to recreate the table when it already exists.

To Reproduce
Steps to reproduce the behavior:

  1. Run Command 'npm run start'
  2. See error

Expected behavior
Server starts without issue.

Console Logs
[Database] Applying missing migrations, if any.
Migration "webauthn1675045120206" failed, error: ER_TABLE_EXISTS_ERROR: Table 'security_keys' already exists
QueryFailedError: ER_TABLE_EXISTS_ERROR: Table 'security_keys' already exists
at Query. (/home/arts/server/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js:165:37)
at Query. (/home/arts/server/node_modules/mysql/lib/Connection.js:526:10)
at Query._callback (/home/arts/server/node_modules/mysql/lib/Connection.js:488:16)
at Sequence.end (/home/arts/server/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query.ErrorPacket (/home/arts/server/node_modules/mysql/lib/protocol/sequences/Query.js:92:8)
at Protocol._parsePacket (/home/arts/server/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/arts/server/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/arts/server/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/arts/server/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/home/arts/server/node_modules/mysql/lib/Connection.js:88:28) {
query: 'CREATE TABLE security_keys (id varchar(255) NOT NULL, user_id varchar(255) NULL, key_id varchar(255) NOT NULL, public_key varchar(255) NOT NULL, counter int NOT NULL, name varchar(255) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB',
parameters: undefined,
driverError: Error: ER_TABLE_EXISTS_ERROR: Table 'security_keys' already exists
at Sequence._packetToError (/home/arts/server/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/home/arts/server/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
at Protocol._parsePacket (/home/arts/server/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/arts/server/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/arts/server/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/arts/server/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/home/arts/server/node_modules/mysql/lib/Connection.js:88:28)
at Socket. (/home/arts/server/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (node:events:519:28)
at Socket.emit (node:domain:488:12)
--------------------
at Protocol._enqueue (/home/arts/server/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at PoolConnection.query (/home/arts/server/node_modules/mysql/lib/Connection.js:198:25)
at /home/arts/server/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js:154:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_TABLE_EXISTS_ERROR',
errno: 1050,
sqlMessage: "Table 'security_keys' already exists",
sqlState: '42S01',
index: 0,
sql: 'CREATE TABLE security_keys (id varchar(255) NOT NULL, user_id varchar(255) NULL, key_id varchar(255) NOT NULL, public_key varchar(255) NOT NULL, counter int NOT NULL, name varchar(255) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB'
},
code: 'ER_TABLE_EXISTS_ERROR',
errno: 1050,
sqlMessage: "Table 'security_keys' already exists",
sqlState: '42S01',
index: 0,
sql: 'CREATE TABLE security_keys (id varchar(255) NOT NULL, user_id varchar(255) NULL, key_id varchar(255) NOT NULL, public_key varchar(255) NOT NULL, counter int NOT NULL, name varchar(255) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB'
}

System Information (please complete the following information):

  • OS: Ubuntu Server
  • Version: 24.04.1 LTS
  • Node Version: v.20.17.0
  • Python 3 Version: 3.12.3

Env and Software info

  • Release: Pre-release (143cbf2)
  • Branch (if release is not applicable): N/A
  • Commit Hash (if release is not applicable): 143cbf2
  • Database: MySQL 8.0.39
  • Reverse Proxy: None (as of now)
  • Thread Count: 8

Additional context
None. Wishing to see help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions