Integrates Drizzle ORM to provide a type-safe and modern solution for PostgreSQL database interactions. Establishes Infisical as the central secret management system, ensuring sensitive database credentials and other environment variables are securely loaded dynamically based on the active environment. Includes a PowerShell script to standardize environment setup for Drizzle CLI operations, fetching secrets from Infisical and local configuration files. New npm scripts `drizzle:push` and `drizzle:pull` are added to streamline database schema migrations. Sets up an initial database module with a `DatabaseService` and a sample `users` schema to demonstrate Drizzle's functionality and integration with Infisical secrets.
26 lines
735 B
TypeScript
26 lines
735 B
TypeScript
import { defineConfig } from 'drizzle-kit';
|
|
|
|
// Environment variables are loaded by launch-drizzle-executable.ps1
|
|
const endpoint = process.env.DATABASE_ENDPOINT;
|
|
const user = process.env.DATABASE_USER;
|
|
const password = process.env.DATABASE_PASSWORD;
|
|
const database = process.env.DATABASE_DATABASE_NAME;
|
|
|
|
if (!endpoint || !user || !password || !database) {
|
|
throw new Error('Missing required database environment variables. Make sure to run via npm script.');
|
|
}
|
|
|
|
export default defineConfig({
|
|
out: './drizzle',
|
|
schema: './src/modules/global/database/schema.ts',
|
|
dialect: 'postgresql',
|
|
dbCredentials: {
|
|
host: endpoint,
|
|
port: 5432,
|
|
user: user,
|
|
password: password,
|
|
database: database,
|
|
ssl: false,
|
|
},
|
|
});
|