Knex Migration Lock Table Creation Fails Due to Missing CREATE TABLE Permission
27.5K reputation · 21 May 2022, 15:48 UTC
When running knex migrate:latest, Knex attempts to create the internal lock table knex_migrations_lock before executing any user migration files. If the database user associated with the Knex instance lacks the CREATE TABLE privilege in the target schema, the operation aborts with an error such as ER_NO_SUCH_TABLE or a permission‑denied message, and the migration process stops.
This behavior is present in all supported dialects (PostgreSQL, MySQL, SQLite) and has been unchanged since the lock table was introduced in Knex 0.15.0 through the 1.x series. Because the lock table is a core part of Knex’s migration concurrency safeguard, the library currently offers no configuration option to disable it or to substitute an external locking mechanism.
Should the lock table creation be made optional via a configuration flag? Can users provide their own locking implementation without forking Knex? Is there a plan to document a supported workaround for environments where the Knex user cannot create tables?