Skip to content

Commit

Permalink
feat: add schema in drizzle instance and disable migrate in production
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Aug 27, 2023
1 parent c2e91b2 commit 5e26798
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libs/DB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';

import * as schema from '@/models/Schema';

import { Env } from './Env.mjs';

const client = createClient({
url: Env.DATABASE_URL,
authToken: Env.DATABASE_AUTH_TOKEN,
});

export const db = drizzle(client);
export const db = drizzle(client, { schema });

await migrate(db, { migrationsFolder: './migrations' });
if (Env.NODE_ENV !== 'production') {
await migrate(db, { migrationsFolder: './migrations' });
}

0 comments on commit 5e26798

Please sign in to comment.