Skip to content

Separate SchemaModule from Kysely. #1703

@igalklebanov

Description

@igalklebanov

Hey 👋

In most cases, kysely.schema is only used in migrations. Migrations are development/CI-time, not runtime.
This is wasteful when looking at runtime bundle sizes. There's a lot of unused code not being shaken out it seems.

So probably:

  1. SchemaModule needs to be exposed in its own path - kysely/schema' probably, and replaced in src/index.ts` with a hint that tells you to import from the new location.

and either:

  1. make Kysely accept an optional SchemaModule in construction.
  2. make kysely.schema use the passed SchemaModule or error telling you to pass it in order to use the getter.
  3. make Migrator reconstruct the Kysely/transaction instance provided to it with SchemaModule out the box so everyone's migration setups/files don't break.

or..

  1. kysely.schema needs to be replaced with an error that tells you to either use SchemaModule directly, or provide ways to enable the legacy way.
  2. A useSchemaGetter (or another name) needs to be implemented to enable legacy way - injecting to Kysely prototype, perhaps module augmentation (tho I remember reading this is deprecated in tsgo?!)
  3. Make Migrator run useSchemaGetter eagerly so everyone's migration files don't break.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiRelated to library's APIbreaking changeIncludes breaking changesdeprecationSomething is/should be deprecatedinternalmigrationsRelated to migrations

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions