Skip to content

feat(effect-drizzle-sqlite): add vendored sqlite adapter - #28547

Merged
kitlangton merged 4 commits into
anomalyco:devfrom
kitlangton:storage-effect-sqlite
May 21, 2026
Merged

kitlangton merged 4 commits into
anomalyco:devfrom
kitlangton:storage-effect-sqlite

Conversation

@kitlangton

@kitlangton kitlangton commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add @opencode-ai/effect-drizzle-sqlite as a package-only vendored Drizzle Effect SQLite adapter
  • expose Effect-yieldable SQLite query builders, transactions, migrations, and narrowed Drizzle-shaped exports
  • keep runtime code on generic Effect SqlClient while using @effect/sql-sqlite-bun only for tests/examples
  • include an opencode-style UserStore service example with static layers, Effect.fn service methods, domain error wrapping, and generated-style migrations

Usage shape

const makeDatabase = EffectDrizzleSqlite.makeWithDefaults()

class Database extends Context.Service<Database, Effect.Success<typeof makeDatabase>>()("@opencode/example/Database") {
  static layer = Layer.effect(Database, makeDatabase).pipe(Layer.provide(sqliteLayer))
}

class UserStore extends Context.Service<UserStore, UserStoreShape>()("@opencode/example/UserStore") {
  static layer = Layer.effect(
    UserStore,
    Effect.gen(function* () {
      const db = yield* Database

      return UserStore.of({
        create: Effect.fn("UserStore.create")(function* (name: string) {
          yield* db.insert(users).values({ name }).pipe(Effect.asVoid)
        }),
        list: Effect.fn("UserStore.list")(function* () {
          return yield* db.select().from(users)
        }),
      })
    }),
  ).pipe(Layer.provide(Database.layer))
}

Notes

  • This does not migrate packages/opencode yet; opencode-specific transaction context, post-commit hooks, paths, and domain stores remain a follow-up.
  • The adapter mirrors Drizzle's Effect Postgres shape where possible, including explicit transaction callbacks.
  • The package includes local typed shims for Drizzle RC2 runtime internals that are not exposed in declarations.

Verification

  • bun typecheck (packages/effect-drizzle-sqlite)
  • bun test --timeout 5000 test/sqlite.test.ts (packages/effect-drizzle-sqlite)
  • bun oxlint packages/effect-drizzle-sqlite/src packages/effect-drizzle-sqlite/test packages/effect-drizzle-sqlite/examples --max-warnings=0
  • bun examples/basic.ts
  • pre-push root bun turbo typecheck

@kitlangton
kitlangton merged commit 5381795 into anomalyco:dev May 21, 2026
11 checks passed
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
isaacfinnegan pushed a commit to isaacfinnegan/whispercode that referenced this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant