Skip to content

Commit

Permalink
add docs to getting started
Browse files Browse the repository at this point in the history
  • Loading branch information
tracehelms committed Nov 13, 2023
1 parent 7e8d768 commit 8cc8ea2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion site/docs/migrations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,21 @@ Migrations can use the `Kysely.schema` module to modify the schema. Migrations c

## Execution order

Execution order of the migrations is the alpabetical order of their names. An excellent way to name your migrations is to prefix them with an ISO 8601 date string. A date prefix works well in large teams where multiple team members may add migrations at the same time in parallel commits without knowing about the other migrations.
There are two options for ordering migrations in Kysely: strict and permissive. Both options are based on the alphanumeric ordering of the migration name. In either case, an excellent way to name your migrations is to prefix them with an ISO 8601 date string.

Strict ordering (the default) will give an error if the alphanumeric order of your migration files does not match the execution order of them in the database. This adds safety by always executing your migrations in the correct, alphanumeric order.

Permissive ordering will allow new migrations to be run even if they are added alphabetically before ones that have already executed. Permissive ordering works well in large teams where multiple team members may add migrations at the same time in parallel commits without knowing about the other migrations. Permissive ordering will run pending (unexecuted) migrations in order when migrating up. When migrating down, migrations will be undone in the opposite order in which they were executed (reverse sorted by execution timestamp).

To use permissive ordering, pass the `migrationOrder` option to Migrator:

```ts
const migrator = new Migrator({
db,
provider: new FileMigrationProvider(...),
migrationOrder: 'permissive'
})
```

## Single file vs multiple file migrations

Expand Down

0 comments on commit 8cc8ea2

Please sign in to comment.