Skip to content

migrate:list command incompatible with plugins that modify the table name #355

@ChrisOpiela

Description

@ChrisOpiela

I apologize if there's a template I am supposed to use, as I didn't see one.

When using a plugin that transforms table names (e.g. to add a prefix), migrate:up, migrate:latest, etc. work fine normally. They seem to properly resolve un-run migrations, transform the names in queries, etc.

But migrate:list doesn't properly resolve which migrations have run and which haven't. I dug into this a little and believe it's because the underlying Migrator in Kysely in #doesTableExist uses introspection and attempts to match the table name from the result (where it wouldn't know a plugin is changing the target table name). Despite the wrong false result here, the other commands continue to work because they actually query the table before working, which allows the plugin to transform the table name. But list just sees that the table doesn't exist and returns a [] for the executed migrations.

Given this is an issue with a specific type of plugin, maybe this is a wontfix, or maybe it should go in the Kysely issue tracker instead. Just thought I'd mention it. This CAN be solved at the plugin level by explicitly defining and prefixing the migration table names, and then ensuring the plugin doesn't prefix again if the incoming table name is already prefixed.

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