tursodatabase / tursodatabase/libsql
Programmatically run drizzle migrations
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Hey, guys!
I'm using drizzle with libsql, and due to some constraints I cannot use drizzle-kit push to run migrations.
I know some drizzle packages have the migrate function which you can use to run migrations programmatically, something lile:
import { drizzle } from 'drizzle-orm/node-postgres'
import { migrate } from 'drizzle-orm/node-postgres/migrator'
import { Pool } from 'pg'
import { Resource } from 'sst'
export const handler = async () => {
const pool = new Pool({
user: Resource.RDS.username,
password: Resource.RDS.password,
database: Resource.RDS.database,
host: Resource.RDS.host,
port: Resource.RDS.port,
})
const db = drizzle(pool)
try {
await migrate(db, { migrationsFolder: './migrations' })
return {
statusCode: 200,
body: JSON.stringify({ message: 'Migrations completed successfully.' }),
}
} catch (err: any) {
return {
statusCode: 500,
body: JSON.stringify({
message: 'Migration failed.',
error: err.message,
}),
}
}
}
And I can't seem to find the migrate function on drizzle libsql package:
import { drizzle } from "drizzle-orm/libsql"
is it possible to do that with libsql?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The request concerns the drizzle-orm/libsql adapter, the migrate API, and drizzle-kit push as the current alternative. Start by checking whether the libsql adapter exposes a migrator comparable to the node-postgres example; done means establishing and documenting a supported programmatic migration path for libSQL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100