Merge branch 'dev' into feat/redirect-tables

This commit is contained in:
Fred KISSIE
2026-09-18 20:59:18 +02:00
197 changed files with 11958 additions and 4383 deletions
+13 -9
View File
@@ -1,5 +1,6 @@
import { drizzle as DrizzlePostgres } from "drizzle-orm/node-postgres";
import { readConfigFile } from "@server/lib/readConfigFile";
import { readEnvOrFile } from "@server/lib/getEnvOrYaml";
import { withReplicas } from "drizzle-orm/pg-core";
import { createPool } from "./poolConfig";
@@ -7,17 +8,20 @@ function createDb() {
const config = readConfigFile();
// check the environment variables for postgres config first before the config file
if (process.env.POSTGRES_CONNECTION_STRING) {
const envConnectionString = readEnvOrFile("POSTGRES_CONNECTION_STRING");
if (envConnectionString) {
config.postgres = {
connection_string: process.env.POSTGRES_CONNECTION_STRING
connection_string: envConnectionString
};
if (process.env.POSTGRES_REPLICA_CONNECTION_STRINGS) {
const replicas =
process.env.POSTGRES_REPLICA_CONNECTION_STRINGS.split(",").map(
(conn) => ({
connection_string: conn.trim()
})
);
const replicaConnectionStrings = readEnvOrFile(
"POSTGRES_REPLICA_CONNECTION_STRINGS"
);
if (replicaConnectionStrings) {
const replicas = replicaConnectionStrings
.split(",")
.map((conn) => ({
connection_string: conn.trim()
}));
config.postgres.replicas = replicas;
}
}
+11 -8
View File
@@ -1,5 +1,6 @@
import { drizzle as DrizzlePostgres } from "drizzle-orm/node-postgres";
import { readConfigFile } from "@server/lib/readConfigFile";
import { readEnvOrFile } from "@server/lib/getEnvOrYaml";
import { withReplicas } from "drizzle-orm/pg-core";
import { build } from "@server/build";
import { db as mainDb } from "./driver";
@@ -17,7 +18,7 @@ function createLogsDb() {
const logsConfig = config.postgres_logs;
// Check environment variable first
let connectionString = process.env.POSTGRES_LOGS_CONNECTION_STRING;
let connectionString = readEnvOrFile("POSTGRES_LOGS_CONNECTION_STRING");
let replicaConnections: Array<{ connection_string: string }> = [];
if (!connectionString && logsConfig) {
@@ -26,13 +27,15 @@ function createLogsDb() {
}
// If POSTGRES_LOGS_REPLICA_CONNECTION_STRINGS is set, use it
if (process.env.POSTGRES_LOGS_REPLICA_CONNECTION_STRINGS) {
replicaConnections =
process.env.POSTGRES_LOGS_REPLICA_CONNECTION_STRINGS.split(",").map(
(conn) => ({
connection_string: conn.trim()
})
);
const replicaConnectionStrings = readEnvOrFile(
"POSTGRES_LOGS_REPLICA_CONNECTION_STRINGS"
);
if (replicaConnectionStrings) {
replicaConnections = replicaConnectionStrings
.split(",")
.map((conn) => ({
connection_string: conn.trim()
}));
}
// If no logs database is configured, fall back to main database
+2
View File
@@ -714,6 +714,8 @@ export const newts = pgTable(
secretHash: varchar("secretHash").notNull(),
dateCreated: varchar("dateCreated").notNull(),
version: varchar("version"),
agent: varchar("agent"), // either newt or cli
agentVersion: varchar("agentVersion"),
siteId: integer("siteId").references(() => sites.siteId, {
onDelete: "cascade"
})