Skip to content

Feature Request: Support per-schema migration tables #349

@normanaranez

Description

@normanaranez

Description:
Problem:
Currently, Kysely uses a single global migration table for all schemas. In multi-schema or multi-tenant setups, this makes it difficult to manage migrations independently for each schema.

Proposed Solution:
Allow specifying a schema for the migration table, for example via a migrationSchema option in defineConfig.

Example Usage:

import { PostgresDialect } from 'kysely'
import { defineConfig } from 'kysely-ctl'
import { Pool } from 'pg'

export default defineConfig({
  destroyOnExit: true,
  dialect: new PostgresDialect({
    pool: new Pool({
      host: 'localhost',
      database: 'recording',
      user: 'postgres',
      password: 'postgres',
      port: 5432,
    }),
  }),
  migrations: {
    migrationFolder: "migrations",
    migrationSchema: "tenant1", // <- proposed new option
  },
})

Benefits:

Enables independent migration tracking per schema.

Avoids conflicts when multiple schemas evolve differently.

Makes multi-tenant or modular database setups easier to manage.

Additional Context:
This is similar to how some ORMs allow schema-specific migration tables, which is very useful for projects with multiple tenants or schema-per-module setups.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configConfig relatedenhancementNew feature or requestmigrateMigrate module related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions