Writing Drizzle code to support two RDBMSs

138 Views Asked by At

I am writing an Drizzle-based Typescript application that will use Postgres in production — but I would really like it to use Sqlite for most tests. Is that even a possibility?

I notice that the examples highlight RDMBS-specific code. For example, from the docs:

import {
  sqliteTable,
  integer,
  text,
  index,
  unique,
} from "drizzle-orm/sqlite-core";

export const users = sqliteTable("users", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  username: text("username").unique().notNull(),
});

Well, that’s great, but how do I do the equivalent thing for both Sqlite and Postgres? If I write two different schema files, which would not be unreasonable, how do I switch between using the different files?

0

There are 0 best solutions below