migrate: Fix 'no such table: migrations' err
Apparently, if you CREATE TABLE inside of a transaction, and then (in the same transaction) do a SELECT on the same table before committing, the table will not exist yet. Now we do the migration in two steps: first initialize the schema; then migrate the data.
This commit is contained in:
parent
f530a543f9
commit
3f09c1517d
@ -33,14 +33,15 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// Migrate database schema
|
||||
m := db.Gormigrate(sqlDB)
|
||||
if err := m.MigrateTo("202010251337"); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// Migrate all files in filestorage
|
||||
if err := sqlDB.Transaction(func(sqlTx *gorm.DB) error {
|
||||
return boltDB.Bolt.View(func(boltTx *bolt.Tx) error {
|
||||
// Migrate database schema
|
||||
m := db.Gormigrate(sqlTx)
|
||||
if err := m.MigrateTo("202010251337"); err != nil {
|
||||
return err
|
||||
}
|
||||
// Migrate all the file uploads
|
||||
allFUs, err := boltdb.AllFileUploads(boltTx)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user