refactor(servicekit): stop linking the State Store and control plane into archie-messaging

This commit is contained in:
sam committed 2026-10-17 17:22:53 +11:00
1 parent c451b1f055
commit 98e7378f2d
6 files changed
+64 -33

No files matched your search

@@ -59,6 +59,23 @@ func Open(ctx context.Context, url string) (*pgxpool.Pool, error) {
return pool, nil
}
// OpenMigrated opens and migrates the pool a service owns its tables in.
// service names the owner in the error an empty database_url produces.
func OpenMigrated(ctx context.Context, url, service string) (*pgxpool.Pool, error) {
if url == "" {
return nil, fmt.Errorf("database_url is required: %s is Postgres-only", service)
}
pool, err := Open(ctx, url)
if err != nil {
return nil, err
}
if err := Migrate(ctx, pool, Migrations()); err != nil {
pool.Close()
return nil, err
}
return pool, nil
}
// Migrate applies the goose migrations in fsys. A session-level advisory lock
// makes processes that start together apply each migration once.
func Migrate(ctx context.Context, pool *pgxpool.Pool, fsys fs.FS) error {