Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the public key/node ID changes, use a database with a separate namespace #225

Open
Tracked by #118
richardhuaaa opened this issue Oct 15, 2024 · 0 comments
Open
Tracked by #118
Assignees

Comments

@richardhuaaa
Copy link
Contributor

richardhuaaa commented Oct 15, 2024

As a starting example (may or may not be the best approach), our unit tests use this approach to create namespaced databases:

func newCtlDB(t testing.TB) (*sql.DB, string, func()) {
return openDB(t, localTestDBDSNPrefix+localTestDBDSNSuffix)
}
func newInstanceDB(t testing.TB, ctx context.Context, ctlDB *sql.DB) (*sql.DB, string, func()) {
dbName := "test_" + RandomStringLower(12)
_, err := ctlDB.Exec("CREATE DATABASE " + dbName)
require.NoError(t, err)
db, dsn, cleanup := openDB(t, localTestDBDSNPrefix+"/"+dbName+localTestDBDSNSuffix)
require.NoError(t, migrations.Migrate(ctx, db))
return db, dsn, func() {
cleanup()
_, err = ctlDB.Exec("DROP DATABASE " + dbName)
require.NoError(t, err)
}
}

Easiest would be to derive the namespace name from the public key, so that for rolling upgrades all new nodes roll onto the same database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants