Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

refactor: remove automatic table migration configuration (#1025)

Sujai Kumar Guptaf072150cb61d
diff --git a/.changeset/remove-auto-move-public-tables.md b/.changeset/remove-auto-move-public-tables.md
new file mode 100644
index 000000000..ee0ae5595
--- /dev/null
+++ b/.changeset/remove-auto-move-public-tables.md
@@ -0,0 +1,5 @@
+---
+'@truefoundry/trueforge': patch
+---
+
+Remove `AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA` and the Postgres bootstrap that moved public tables into `POSTGRES_SCHEMA`; schema creation stays with the Migrator and init migration.
diff --git a/packages/trueforge/.env.example b/packages/trueforge/.env.example
index 48b001e2b..684ed8de2 100644
--- a/packages/trueforge/.env.example
+++ b/packages/trueforge/.env.example
@@ -234,8 +234,6 @@ POSTGRES_PORT=5432
## Postgres schema for app tables + Kysely migration bookkeeping (default: trueforge).
# POSTGRES_SCHEMA=trueforge
-## When set, automatically move TrueForge tables from the public schema to POSTGRES_SCHEMA.
-# AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA=true
## ---------------------------------------------------------------------------
## OIDC (used when STANDALONE=false). All three must be set together, or all
diff --git a/packages/trueforge/src/config.ts b/packages/trueforge/src/config.ts
index c180c8890..daacd98fc 100644
--- a/packages/trueforge/src/config.ts
+++ b/packages/trueforge/src/config.ts
@@ -1001,15 +1001,6 @@ export type DistributedServerConfiguration = SharedServerConfiguration & {
* caller's token. Unset = local Postgres stores. Mutually exclusive with OIDC.
* Env: `TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL`.
*/
- /**
- * When set, automatically move public TrueForge tables into `POSTGRES_SCHEMA` on first bootstrap.
- * Env: `AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA`. Default true.
- */
- AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA: boolean;
- /**
- * The URL of the TrueFoundry ServiceFoundry server.
- * Env: `TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL`.
- */
TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL: string | undefined;
/**
* Required when `TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL` is set. Env: `TRUEFOUNDRY_API_KEY`.
@@ -1353,11 +1344,6 @@ const configuration: ServerConfiguration = standalone
REDIS_TLS_KEY: getEnv('REDIS_TLS_KEY'),
REDIS_TLS_KEY_PASSPHRASE: getEnv('REDIS_TLS_KEY_PASSPHRASE'),
OIDC: resolveOIDCConfig(),
- AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA: parseBoolean({
- envKey: 'AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA',
- raw: getEnv('AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA'),
- defaultValue: true,
- }),
TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL: getEnv('TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL', { required: false }),
TRUEFOUNDRY_API_KEY: getEnv('TRUEFOUNDRY_API_KEY', { required: false }),
TRUEFOUNDRY_SERVICEFOUNDRY_HTTP_TIMEOUT_MS: parsePositiveInt({
diff --git a/packages/trueforge/src/db/migratePostgres.ts b/packages/trueforge/src/db/migratePostgres.ts
index a0d83d85b..06d106daf 100644
--- a/packages/trueforge/src/db/migratePostgres.ts
+++ b/packages/trueforge/src/db/migratePostgres.ts
@@ -4,7 +4,7 @@ import path from 'node:path';
import type { Kysely } from 'kysely';
import { FileMigrationProvider, Migrator } from 'kysely/migration';
import { importAbsoluteModule } from '../util/crossPlatform';
-import { ensureTrueforgeSchema, getTrueForgePostgresSchema } from './postgres/schema';
+import { getTrueForgePostgresSchema } from './postgres/schema';
import type { Database } from './postgres/types';
function createMigrator(db: Kysely<Database>): Migrator {
@@ -21,7 +21,6 @@ function createMigrator(db: Kysely<Database>): Migrator {
}
async function runMigrations(input: { db: Kysely<Database>; targetMigrationName: string | undefined }): Promise<void> {
- await ensureTrueforgeSchema(input.db);
const migrator = createMigrator(input.db);
const { error, results } =
diff --git a/packages/trueforge/src/db/postgres/schema.ts b/packages/trueforge/src/db/postgres/schema.ts
index d73381109..dfc325182 100644
--- a/packages/trueforge/src/db/postgres/schema.ts
+++ b/packages/trueforge/src/db/postgres/schema.ts
@@ -1,7 +1,4 @@
-import { type Kysely, sql } from 'kysely';
-
import configuration from '../../config';
-import type { Database } from './types';
export function getTrueForgePostgresSchema(): string {
if (configuration.STANDALONE) {
@@ -9,54 +6,3 @@ export function getTrueForgePostgresSchema(): string {
}
return configuration.POSTGRES_SCHEMA;
}
-
-const TABLES_TO_MOVE = [
- 'kysely_migration',
- 'kysely_migration_lock',
- 'session',
- 'turn',
- 'turn_thread',
- 'session_event',
- 'thread_context_log',
- 'thread_capability_state',
- 'model_provider',
- 'skill',
- 'sandbox_provider',
- 'agent',
- 'schedule',
- 'schedule_run',
- 'mcp_server',
- 'oauth_token',
- 'oauth_pending_authorization',
-] as const;
-
-export async function ensureTrueforgeSchema(db: Kysely<Database>): Promise<void> {
- const schema = getTrueForgePostgresSchema();
- await db.transaction().execute(async txn => {
- await sql`SET LOCAL lock_timeout = '5s'`.execute(txn);
- await sql`SELECT pg_advisory_xact_lock(hashtext(${`trueforge_schema_bootstrap:${schema}`}))`.execute(txn);
-
- const result = await sql<{ exists: boolean }>`
- SELECT EXISTS (
- SELECT 1
- FROM pg_namespace
- WHERE nspname = ${schema}
- ) AS exists
- `.execute(txn);
- if (result.rows[0]?.exists === true) {
- return;
- }
-
- await sql`CREATE SCHEMA IF NOT EXISTS ${sql.id(schema)}`.execute(txn);
- if (
- !configuration.STANDALONE &&
- configuration.AUTOMATICALLY_MOVE_TRUEFORGE_TABLES_FROM_PUBLIC_TO_TRUEFORGE_SCHEMA
- ) {
- for (const tableName of TABLES_TO_MOVE) {
- await sql`
- ALTER TABLE IF EXISTS ${sql.id('public', tableName)} SET SCHEMA ${sql.id(schema)}
- `.execute(txn);
- }
- }
- });
-}