Skip to content

Migrator attempts to create schema even when it exists #1552

@mordae

Description

@mordae

Hi, it seems migrator.js attempts to create schema even when it already exists:

  async #ensureMigrationTableExists(): Promise<void> {
    if (!(await this.#doesTableExists(this.#migrationTable))) {
      try {
        if (this.#migrationTableSchema) {
          // ⚠️ note the absence of existence check here,
          //    the whole block is also likely redundant
          await this.#createIfNotExists(
            this.#props.db.schema.createSchema(this.#migrationTableSchema),
          )
        }

I think this should have been taken care of by:

  async #ensureMigrationTablesExists(): Promise<void> {
    await this.#ensureMigrationTableSchemaExists()  // ✔️ creates schema
    await this.#ensureMigrationTableExists()        // ✔️ uses it
    await this.#ensureMigrationLockTableExists()
    await this.#ensureLockRowExists()
  }

Or am I missing something?

In practice this breaks my use case with custom Oracle 19 adapter built with kysely-oracledb.

Metadata

Metadata

Labels

enhancementNew feature or requestmigrationsRelated to migrations

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions