Expected schema does not match actual for bandwidth.db and used_serial.db after recreating them

Hello,

All of sudden I’ve been having problems with the storagenode image, and turned out that my bandwidth and used_serial databases were totally corrupt. I did try indeed to run integrity checks on them with a ‘database is not a file’ error as a result, and tried the dump on a sql file method, creating empty databases.

At this point I just decided to throw those databases away and let storagenode recreate them (althought I know it should not be done unless necessary, but here I thought it was my only solution) .

As a result, both databases now give me the famous schema unmatching problem in the logs :

020-03-28T16:34:10.422Z        INFO    Configuration loaded from: /app/config/config.yaml
2020-03-28T16:34:10.431Z        INFO    Operator email: cabrasm@outlook.com
2020-03-28T16:34:10.431Z        INFO    operator wallet: 0xefd4c1e7730f7b00e1Ac8438BbBDC2a1cD1cE93E
2020-03-28T16:34:10.959Z        INFO    version running on version v0.34.6
2020-03-28T16:34:10.970Z        INFO    db.migration    Database Version        {"version": 31}
Error: Error during preflight check for storagenode databases: storage node preflight database error: used_serial: expected schema does not match actual:   &dbschema.Schema{
-       Tables: []*dbschema.Table{
-               &{
-                       Name: "used_serial_",
-                       Columns: []*dbschema.Column{
-                               &{Name: "expiration", Type: "TIMESTAMP"},
-                               &{Name: "satellite_id", Type: "BLOB"},
-                               &{Name: "serial_number", Type: "BLOB"},
-                       },
-               },
-       },
+       Tables: nil,
-       Indexes: []*dbschema.Index{
-               &{Name: "idx_used_serial_", Table: "used_serial_", Columns: []string{"expiration"}},
-               &{
-                       Name:    "pk_used_serial_",
-                       Table:   "used_serial_",
-                       Columns: []string{"satellite_id", "serial_number"},
-               },
-       },
+       Indexes: nil,
  }

        storj.io/storj/storagenode/storagenodedb.(*DB).Preflight:301
        main.cmdRun:198
        storj.io/storj/pkg/process.cleanup.func1.2:312
        storj.io/storj/pkg/process.cleanup.func1:330
        github.com/spf13/cobra.(*Command).execute:826
        github.com/spf13/cobra.(*Command).ExecuteC:914
        github.com/spf13/cobra.(*Command).Execute:864
        storj.io/storj/pkg/process.ExecWithCustomConfig:84
        storj.io/storj/pkg/process.ExecCustomDebug:66
        main.main:328
        runtime.main:203
2020-03-28T16:34:13.556Z        INFO    Configuration loaded from: /app/config/config.yaml
2020-03-28T16:34:13.565Z        INFO    Operator email: cabrasm@outlook.com
2020-03-28T16:34:13.565Z        INFO    operator wallet: 0xefd4c1e7730f7b00e1Ac8438BbBDC2a1cD1cE93E
2020-03-28T16:34:14.085Z        INFO    version running on version v0.34.6
2020-03-28T16:34:14.095Z        INFO    db.migration    Database Version        {"version": 31}
Error: Error during preflight check for storagenode databases: storage node preflight database error: bandwidth: expected schema does not match actual:   &dbschema.Schema{
-       Tables: []*dbschema.Table{
-               &{
-                       Name: "bandwidth_usage",
-                       Columns: []*dbschema.Column{
-                               &{Name: "action", Type: "INTEGER"},
-                               &{Name: "amount", Type: "BIGINT"},
-                               &{Name: "created_at", Type: "TIMESTAMP"},
-                               &{Name: "satellite_id", Type: "BLOB"},
-                       },
-               },
-               &{
-                       Name: "bandwidth_usage_rollups",
-                       Columns: []*dbschema.Column{
-                               &{Name: "action", Type: "INTEGER"},
-                               &{Name: "amount", Type: "BIGINT"},
-                               &{Name: "interval_start", Type: "TIMESTAMP"},
-                               &{Name: "satellite_id", Type: "BLOB"},
-                       },
-                       PrimaryKey: []string{"action", "interval_start", "satellite_id"},
-               },
-       },
+       Tables: nil,
-       Indexes: []*dbschema.Index{
-               &{
-                       Name:    "idx_bandwidth_usage_created",
-                       Table:   "bandwidth_usage",
-                       Columns: []string{"created_at"},
-               },
-               &{
-                       Name:    "idx_bandwidth_usage_satellite",
-                       Table:   "bandwidth_usage",
-                       Columns: []string{"satellite_id"},
-               },
-       },
+       Indexes: nil,
  }

        storj.io/storj/storagenode/storagenodedb.(*DB).Preflight:301
        main.cmdRun:198
        storj.io/storj/pkg/process.cleanup.func1.2:312
        storj.io/storj/pkg/process.cleanup.func1:330
        github.com/spf13/cobra.(*Command).execute:826
        github.com/spf13/cobra.(*Command).ExecuteC:914
        github.com/spf13/cobra.(*Command).Execute:864
        storj.io/storj/pkg/process.ExecWithCustomConfig:84
        storj.io/storj/pkg/process.ExecCustomDebug:66
        main.main:328
        runtime.main:203

And I’ve been looking for sql queries to recreate them manually without success.

Any help would be appreciated, I see the community support is amazing around here and I just thank you all in advance for the help!

Manuel