Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: skip sample instance during backfile history if bytebase db not found (#5528)

Tianzhou (天舟)0155564e606c
diff --git a/backend/resources/postgres/postgres.go b/backend/resources/postgres/postgres.go
index 40d3cfc49e..0476e0994b 100644
--- a/backend/resources/postgres/postgres.go
+++ b/backend/resources/postgres/postgres.go
@@ -34,6 +34,8 @@ import (
var sampleFS embed.FS
const (
+ // SampleInstanceResourceID is the resource id for the sample database.
+ SampleInstanceResourceID = "postgres-sample"
// SampleUser is the user name for the sample database.
SampleUser = "bbsample"
// SampleDatabase is the sample database name.
diff --git a/backend/server/server.go b/backend/server/server.go
index dd78125a28..233efa41d8 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -988,7 +988,7 @@ func (s *Server) generateOnboardingData(ctx context.Context, userID int) error {
}
instance, err := s.store.CreateInstanceV2(ctx, api.DefaultProdEnvironmentID, &store.InstanceMessage{
- ResourceID: "postgres-sample",
+ ResourceID: postgres.SampleInstanceResourceID,
Title: "Postgres Sample Instance",
Engine: db.Postgres,
ExternalLink: "",
@@ -1212,6 +1212,11 @@ func (s *Server) backfillInstanceChangeHistory(ctx context.Context) {
driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "bytebase")
if err != nil {
+ // Sample instance may not have the "bytebase" database in the old version,
+ // unless user has performed a migration.
+ if instance.ResourceID == postgres.SampleInstanceResourceID {
+ return nil
+ }
return err
}
defer driver.Close(ctx)