You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Get the internal systemDB instance to check tables directly
351
+
dbosCtx, ok:=ctx.(*dbosContext)
352
+
require.True(t, ok, "expected dbosContext")
353
+
require.NotNil(t, dbosCtx.systemDB)
354
+
355
+
sysDB, ok:=dbosCtx.systemDB.(*sysDB)
356
+
require.True(t, ok, "expected sysDB")
357
+
358
+
// Verify schema name was set correctly
359
+
assert.Equal(t, customSchema, sysDB.schema, "schema name should match custom schema")
360
+
361
+
// Verify all expected tables exist in the custom schema
362
+
dbCtx:=context.Background()
363
+
364
+
// Test workflow_status table in custom schema
365
+
varexistsbool
366
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = $1 AND table_name = 'workflow_status')", customSchema).Scan(&exists)
367
+
require.NoError(t, err)
368
+
assert.True(t, exists, "workflow_status table should exist in custom schema")
369
+
370
+
// Test operation_outputs table in custom schema
371
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = $1 AND table_name = 'operation_outputs')", customSchema).Scan(&exists)
372
+
require.NoError(t, err)
373
+
assert.True(t, exists, "operation_outputs table should exist in custom schema")
374
+
375
+
// Test workflow_events table in custom schema
376
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = $1 AND table_name = 'workflow_events')", customSchema).Scan(&exists)
377
+
require.NoError(t, err)
378
+
assert.True(t, exists, "workflow_events table should exist in custom schema")
379
+
380
+
// Test notifications table in custom schema
381
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = $1 AND table_name = 'notifications')", customSchema).Scan(&exists)
382
+
require.NoError(t, err)
383
+
assert.True(t, exists, "notifications table should exist in custom schema")
384
+
385
+
// Test that all tables can be queried using custom schema (empty results expected)
386
+
rows, err:=sysDB.pool.Query(dbCtx, fmt.Sprintf("SELECT workflow_uuid FROM %s.workflow_status LIMIT 1", customSchema))
387
+
require.NoError(t, err)
388
+
rows.Close()
389
+
390
+
rows, err=sysDB.pool.Query(dbCtx, fmt.Sprintf("SELECT workflow_uuid FROM %s.operation_outputs LIMIT 1", customSchema))
391
+
require.NoError(t, err)
392
+
rows.Close()
393
+
394
+
rows, err=sysDB.pool.Query(dbCtx, fmt.Sprintf("SELECT workflow_uuid FROM %s.workflow_events LIMIT 1", customSchema))
395
+
require.NoError(t, err)
396
+
rows.Close()
397
+
398
+
rows, err=sysDB.pool.Query(dbCtx, fmt.Sprintf("SELECT destination_uuid FROM %s.notifications LIMIT 1", customSchema))
399
+
require.NoError(t, err)
400
+
rows.Close()
401
+
402
+
// Check that the dbos_migrations table exists in custom schema
403
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = $1 AND table_name = 'dbos_migrations')", customSchema).Scan(&exists)
404
+
require.NoError(t, err)
405
+
assert.True(t, exists, "dbos_migrations table should exist in custom schema")
406
+
407
+
// Verify migration version is 1 (after initial migration)
408
+
varversionint64
409
+
varcountint
410
+
err=sysDB.pool.QueryRow(dbCtx, fmt.Sprintf("SELECT COUNT(*) FROM %s.dbos_migrations", customSchema)).Scan(&count)
411
+
require.NoError(t, err)
412
+
assert.Equal(t, 1, count, "dbos_migrations table should have exactly one row")
413
+
414
+
err=sysDB.pool.QueryRow(dbCtx, fmt.Sprintf("SELECT version FROM %s.dbos_migrations", customSchema)).Scan(&version)
415
+
require.NoError(t, err)
416
+
assert.Equal(t, int64(1), version, "migration version should be 1 (after initial migration)")
417
+
418
+
// Test manual shutdown and recreate with same custom schema
419
+
ctx.Shutdown(1*time.Minute)
420
+
421
+
// Recreate context with same custom schema - should have no error since DB is already migrated
0 commit comments