Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist
/helpers
migration.*
/test/browser/bundle.js
node_modules
.vscode
Expand Down
3 changes: 2 additions & 1 deletion jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"./helpers/mysql": "./src/helpers/mysql.ts",
"./helpers/mssql": "./src/helpers/mssql.ts",
"./helpers/postgres": "./src/helpers/postgres.ts",
"./helpers/sqlite": "./src/helpers/sqlite.ts"
"./helpers/sqlite": "./src/helpers/sqlite.ts",
"./migration": "./src/migration/index.ts"
},
"publish": {
"include": [
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"files": [
"dist",
"helpers",
"migration.d.ts",
"migration.js",
"outdated-typescript.d.ts"
],
"exports": {
Expand Down Expand Up @@ -66,6 +68,11 @@
"import": "./dist/esm/helpers/sqlite.js",
"require": "./dist/cjs/helpers/sqlite.js",
"default": "./dist/cjs/helpers/sqlite.js"
},
"./migration": {
"import": "./dist/esm/migration/index.js",
"require": "./dist/cjs/migration/index.js",
"default": "./dist/cjs/migration/index.js"
}
},
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions site/docs/migrations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ There is also an `allowUnorderedMigrations` option. This option will allow new m
To allow unordered migrations, pass the `allowUnorderedMigrations` option to Migrator:

```ts
import { FileMigrationProvider, Migrator } from 'kysely/migration'

const migrator = new Migrator({
db,
provider: new FileMigrationProvider(...),
Expand Down Expand Up @@ -140,6 +142,8 @@ For more information, visit https://github.com/kysely-org/kysely-ctl.
You can then use:

```ts
import { Migrator } from 'kysely/migration'

const migrator = new Migrator(migratorConfig)
await migrator.migrateToLatest()
```
Expand All @@ -152,12 +156,8 @@ You will probably want to add a simple migration script to your projects like th
import * as path from 'path'
import { Pool } from 'pg'
import { promises as fs } from 'fs'
import {
Kysely,
Migrator,
PostgresDialect,
FileMigrationProvider,
} from 'kysely'
import { Kysely, PostgresDialect } from 'kysely'
import { FileMigrationProvider, Migrator } from 'kysely/migration'
import { Database } from './types'

async function migrateToLatest() {
Expand Down
78 changes: 76 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,82 @@ export * from './dialect/pglite/pglite-dialect-config.js'
export * from './query-compiler/default-query-compiler.js'
export * from './query-compiler/query-compiler.js'

export * from './migration/migrator.js'
export * from './migration/file-migration-provider.js'
export {
/**
* @deprecated import from 'kysely/migration' instead.
*/
DEFAULT_ALLOW_UNORDERED_MIGRATIONS,
/**
* @deprecated import from 'kysely/migration' instead.
*/
DEFAULT_MIGRATION_LOCK_TABLE,
/**
* @deprecated import from 'kysely/migration' instead.
*/
DEFAULT_MIGRATION_TABLE,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MIGRATION_LOCK_ID,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MigrateOptions,
/**
* @deprecated import from 'kysely/migration' instead.
*/
Migration,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MigrationInfo,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MigrationProvider,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MigrationResult,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MigrationResultSet,
/**
* @deprecated import from 'kysely/migration' instead.
*/
Migrator,
/**
* @deprecated import from 'kysely/migration' instead.
*/
MigratorProps,
/**
* @deprecated import from 'kysely/migration' instead.
*/
NO_MIGRATIONS,
/**
* @deprecated import from 'kysely/migration' instead.
*/
NoMigrations,
} from './migration/migrator.js'
export {
/**
* @deprecated import from 'kysely/migration' instead.
*/
FileMigrationProvider,
/**
* @deprecated import from 'kysely/migration' instead.
*/
FileMigrationProviderFS,
/**
* @deprecated import from 'kysely/migration' instead.
*/
FileMigrationProviderPath,
/**
* @deprecated import from 'kysely/migration' instead.
*/
FileMigrationProviderProps,
} from './migration/file-migration-provider.js'

export * from './plugin/kysely-plugin.js'
export * from './plugin/camel-case/camel-case-plugin.js'
Expand Down
2 changes: 2 additions & 0 deletions src/migration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './file-migration-provider.js'
export * from './migrator.js'