diff --git a/bun.lockb b/bun.lockb index 4c7d0daba..7a020f13e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/migrate.ts b/migrate.ts deleted file mode 100644 index d83593089..000000000 --- a/migrate.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { MigrationConfig } from 'drizzle-orm/migrator'; -import { drizzle } from 'drizzle-orm/node-postgres'; -import { migrate } from 'drizzle-orm/node-postgres/migrator'; -import { cleanEnv, str } from 'envalid'; -import { Client } from 'pg'; -import pino from 'pino'; - -const logger = pino({ - transport: - process.env.NODE_ENV === 'development' - ? { - target: 'pino-pretty', - } - : undefined, -}); - -logger.info('Migration script started'); - -logger.child({ module: 'env' }).debug('Validating environment variables'); -const env = cleanEnv(process.env, { - // biome-ignore lint/style/useNamingConvention: This is an environment variable - DATABASE_URL: str({ desc: 'PostgreSQL URL' }), -}); - -const migrationOptions = { - migrationsFolder: './drizzle', -} satisfies MigrationConfig; - -logger.child({ module: 'db' }).info('Connecting to database'); -const client = new Client({ connectionString: env.DATABASE_URL }); -await client.connect(); -const db = drizzle(client); - -logger.child({ module: 'migrations' }).info('Running migrations'); -await migrate(db, migrationOptions); -logger.child({ module: 'migrations' }).info('Migrations finished'); - -logger.child({ module: 'db' }).info('Closing database connection'); -await client.end(); -logger.child({ module: 'db' }).info('Database connection closed'); - -logger.info('Migration script finished'); diff --git a/package.json b/package.json index b320328f3..4d834daed 100644 --- a/package.json +++ b/package.json @@ -10,21 +10,17 @@ "format:write": "bun run format --write", "lint": "biome check .", "lint:fix": "biome check . --apply-unsafe", - "migrate": "bun ./migrate.ts", + "migrate": "drizzle-kit migrate", "migrate:create": "drizzle-kit generate", "test": "bun run lint && bun run format && turbo run build type-check", "type-check": "turbo run type-check" }, "dependencies": { "drizzle-kit": "0.22.1", - "envalid": "8.0.0", - "pg": "8.11.3", - "pino": "9.1.0", - "pino-pretty": "10.3.1" + "envalid": "8.0.0" }, "devDependencies": { "@biomejs/biome": "1.7.3", - "@types/pg": "8.11.4", "prettier": "3.2.5", "prettier-plugin-packagejson": "2.5.0", "prettier-plugin-tailwindcss": "0.6.1",