Skip to content

Commit f20c480

Browse files
authored
allow SSL config for drizzle-kit, fix migration 61 (#1024)
1 parent 79b504a commit f20c480

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

frontend/drizzle.config.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
import { config } from 'dotenv';
2-
import { defineConfig } from 'drizzle-kit';
2+
import { defineConfig, type Config } from 'drizzle-kit';
3+
import { getDatabaseConfig } from './lib/db/drizzle';
34

45
config({ path: '.env.local' });
56

7+
const dbConfig = getDatabaseConfig();
8+
const dbCredentials: Record<string, string | number | Record<string, any>> = {
9+
user: dbConfig.username!,
10+
password: dbConfig.password,
11+
host: dbConfig.host!,
12+
port: dbConfig.port,
13+
database: dbConfig.database,
14+
};
15+
16+
if (process.env.DATABASE_SSL_ROOT_CERT) {
17+
dbCredentials.ssl = {
18+
ca: process.env.DATABASE_SSL_ROOT_CERT,
19+
};
20+
}
21+
22+
623
export default defineConfig({
7-
dialect: 'postgresql',
8-
dbCredentials: {
9-
url: process.env.DATABASE_URL!,
10-
},
11-
schema: './lib/db/migrations/schema.ts',
12-
out: './lib/db/migrations',
24+
dialect: "postgresql",
25+
dbCredentials,
26+
schema: "./lib/db/migrations/schema.ts",
27+
out: "./lib/db/migrations",
1328
entities: {
1429
roles: {
15-
provider: 'supabase',
16-
}
17-
}
18-
});
30+
provider: "supabase",
31+
},
32+
},
33+
} as Config);

frontend/lib/db/drizzle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const getDatabaseConfigFromEnv = (): DatabaseConfig => {
6565
};
6666

6767
// Get database configuration from either DATABASE_URL or individual env vars
68-
const getDatabaseConfig = (): DatabaseConfig => {
68+
export const getDatabaseConfig = (): DatabaseConfig => {
6969
if (env.DATABASE_URL) {
7070
return parseDatabaseUrl(env.DATABASE_URL);
7171
} else {
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
ALTER TABLE "tag_classes" DROP CONSTRAINT "tag_classes_name_project_id_unique";--> statement-breakpoint
21
ALTER TABLE "event_definitions" DROP CONSTRAINT "event_definitions_project_id_fkey";
32
--> statement-breakpoint
43
ALTER TABLE "project_api_keys" ADD COLUMN "is_ingest_only" boolean DEFAULT false NOT NULL;--> statement-breakpoint
5-
ALTER TABLE "tag_classes" DROP COLUMN "evaluator_runnable_graph";--> statement-breakpoint
6-
ALTER TABLE "tag_classes" DROP COLUMN "pipeline_version_id";--> statement-breakpoint
7-
ALTER TABLE "tags" DROP COLUMN "class_id";--> statement-breakpoint
8-
ALTER TABLE "tag_classes" ADD CONSTRAINT "label_classes_name_project_id_unique" UNIQUE("name","project_id");--> statement-breakpoint

0 commit comments

Comments
 (0)