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
190
+
dbosCtx, ok:=ctx.(*dbosContext)
191
+
require.True(t, ok, "expected dbosContext")
192
+
require.NotNil(t, dbosCtx.systemDB)
193
+
194
+
sysDB, ok:=dbosCtx.systemDB.(*sysDB)
195
+
require.True(t, ok, "expected sysDB")
196
+
197
+
// Verify all expected tables exist and have correct structure
198
+
dbCtx:=context.Background()
199
+
200
+
// Test workflow_status table
201
+
varexistsbool
202
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'dbos' AND table_name = 'workflow_status')").Scan(&exists)
203
+
require.NoError(t, err)
204
+
assert.True(t, exists, "workflow_status table should exist")
205
+
206
+
// Test operation_outputs table
207
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'dbos' AND table_name = 'operation_outputs')").Scan(&exists)
208
+
require.NoError(t, err)
209
+
assert.True(t, exists, "operation_outputs table should exist")
210
+
211
+
// Test workflow_events table
212
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'dbos' AND table_name = 'workflow_events')").Scan(&exists)
213
+
require.NoError(t, err)
214
+
assert.True(t, exists, "workflow_events table should exist")
215
+
216
+
// Test notifications table
217
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'dbos' AND table_name = 'notifications')").Scan(&exists)
218
+
require.NoError(t, err)
219
+
assert.True(t, exists, "notifications table should exist")
220
+
221
+
// Test that all tables can be queried (empty results expected)
222
+
rows, err:=sysDB.pool.Query(dbCtx, "SELECT workflow_uuid FROM dbos.workflow_status LIMIT 1")
223
+
require.NoError(t, err)
224
+
rows.Close()
225
+
226
+
rows, err=sysDB.pool.Query(dbCtx, "SELECT workflow_uuid FROM dbos.operation_outputs LIMIT 1")
227
+
require.NoError(t, err)
228
+
rows.Close()
229
+
230
+
rows, err=sysDB.pool.Query(dbCtx, "SELECT workflow_uuid FROM dbos.workflow_events LIMIT 1")
231
+
require.NoError(t, err)
232
+
rows.Close()
233
+
234
+
rows, err=sysDB.pool.Query(dbCtx, "SELECT destination_uuid FROM dbos.notifications LIMIT 1")
235
+
require.NoError(t, err)
236
+
rows.Close()
237
+
238
+
// Check that the dbos_migrations table exists and has one row with the correct version
239
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'dbos' AND table_name = 'dbos_migrations')").Scan(&exists)
240
+
require.NoError(t, err)
241
+
assert.True(t, exists, "dbos_migrations table should exist")
242
+
243
+
// Verify migration version is 1 (after initial migration)
244
+
varversionint64
245
+
varcountint
246
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT COUNT(*) FROM dbos.dbos_migrations").Scan(&count)
247
+
require.NoError(t, err)
248
+
assert.Equal(t, 1, count, "dbos_migrations table should have exactly one row")
249
+
250
+
err=sysDB.pool.QueryRow(dbCtx, "SELECT version FROM dbos.dbos_migrations").Scan(&version)
251
+
require.NoError(t, err)
252
+
assert.Equal(t, int64(1), version, "migration version should be 1 (after initial migration)")
253
+
254
+
// Test manual shutdown and recreate
255
+
ctx.Shutdown(1*time.Minute)
256
+
257
+
// Recreate context - should have no error since DB is already migrated
0 commit comments