Is there a way to handle migrations with .sql files?
I enjoy being able to control the specific queries in the migration files. To do this, I use postgrator (https://www.npmjs.com/package/postgrator) along with a custom script that also manages which environment should run each file. Does Kysely migrations also support this feature (migrations with only .sql files)?
npm
postgrator
A SQL migration tool for SQL people. Latest version: 7.2.0, last published: 7 months ago. Start using postgrator in your project by running
npm i postgrator
. There are 37 other projects in the npm registry using postgrator.Solution:Jump to solution
But nothing prevents you from using a separate tool for migrations. There's no benefit from using Kysely's migrations. And to be honest, the migration module has received very little love. It's quite bare-bones.
2 Replies
You can implement your own
MigrationProvider
. The interface is dead-simple: https://kysely-org.github.io/kysely-apidoc/interfaces/MigrationProvider.html
You can execute the raw SQL you read from a file using sql.raw(theSql).execute(db)
.MigrationProvider | kysely
Documentation for kysely
Solution
But nothing prevents you from using a separate tool for migrations. There's no benefit from using Kysely's migrations. And to be honest, the migration module has received very little love. It's quite bare-bones.