Browse Source

do not make migration failure fatal temporarily

pull/1855/head
Gabe Kangas 4 years ago
parent
commit
f173b8deca
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
  1. 7
      core/data/migrations.go

7
core/data/migrations.go

@ -17,12 +17,12 @@ func migrateToSchema5(db *sql.DB) {
// Authenticated bool added to the users table. // Authenticated bool added to the users table.
stmt, err := db.Prepare("ALTER TABLE users ADD authenticated_at timestamp DEFAULT null") stmt, err := db.Prepare("ALTER TABLE users ADD authenticated_at timestamp DEFAULT null")
if err != nil { if err != nil {
log.Fatal(err) log.Errorln("error running migration, you may experience issues: ", err)
} }
defer stmt.Close() defer stmt.Close()
_, err = stmt.Exec() _, err = stmt.Exec()
if err != nil { if err != nil {
log.Warnln(err) log.Errorln("error running migration, you may experience issues: ", err)
} }
// Migrate the access tokens from the users table to the access tokens table. // Migrate the access tokens from the users table to the access tokens table.
@ -52,7 +52,6 @@ func migrateToSchema5(db *sql.DB) {
smt := `INSERT INTO user_access_tokens(token, user_id, timestamp) VALUES %s ON CONFLICT DO NOTHING` smt := `INSERT INTO user_access_tokens(token, user_id, timestamp) VALUES %s ON CONFLICT DO NOTHING`
smt = fmt.Sprintf(smt, strings.Join(valueStrings, ",")) smt = fmt.Sprintf(smt, strings.Join(valueStrings, ","))
// fmt.Println(smt)
tx, err := db.Begin() tx, err := db.Begin()
if err != nil { if err != nil {
log.Fatalln("Error starting transaction", err) log.Fatalln("Error starting transaction", err)
@ -67,7 +66,7 @@ func migrateToSchema5(db *sql.DB) {
} }
// Remove old access token column from the users table. // Remove old access token column from the users table.
stmt, err = db.Prepare("ALTER TABLE users DROP COLUMN access_token;") stmt, err = db.Prepare("ALTER TABLE users DROP COLUMN access_token")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

Loading…
Cancel
Save