Adds Drizzle ORM with Infisical for secure database management
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.
This commit is contained in:
1 parent
6aec3e91b8
commit
469e799b01
13 files changed
+1651
-4
No files matched your search
@@ -0,0 +1,25 @@
|
||||
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,
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user