Skip to content

Commit

Permalink
doc: migration path
Browse files Browse the repository at this point in the history
  • Loading branch information
acro5piano committed Jun 16, 2024
1 parent 2d09efb commit acdb3c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ import { Kysely, Migrator, PostgresDialect, FileMigrationProvider } from 'kysely
import { run } from 'kysely-migration-cli'

// For ESM environment
const migrationFolder = new URL('./migrations', import.meta.url).pathname
const migrationFolder = new URL('../migrations', import.meta.url).pathname

// For CJS environment
// const migrationFolder = path.join(__dirname, './migrations')
// const migrationFolder = path.join(__dirname, '../migrations')

const db = new Kysely<any>({
const db = new Kysely({
dialect: new PostgresDialect({
pool: new pg.Pool({
connectionString: process.env.DATABASE_URL,
Expand All @@ -58,6 +58,8 @@ const migrator = new Migrator({
run(db, migrator, migrationFolder)
```

Note: The above script assumes your migration folder is located at the same directory of chdir and named `./migrations`

Then run:

```bash
Expand Down

0 comments on commit acdb3c2

Please sign in to comment.