tursodatabase / tursodatabase/libsql

Programmatically run drizzle migrations

Open
#1,936 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.