···55func GenerateAlnumString(length int) []byte {
66 const CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
77 res := []byte{}
88- for i := 0; i < length; i++ {
88+ for range length {
99 res = append(res, CHARS[rand.Intn(len(CHARS))])
1010 }
1111 return res
+1-5
controller/migrator.go
···99 "github.com/jmoiron/sqlx"
1010)
11111212-const DB_VERSION int = 5
1212+const DB_VERSION int = 4
13131414func CheckDBVersionAndMigrate(db *sqlx.DB) {
1515 db.MustExec("CREATE SCHEMA IF NOT EXISTS arimelody")
···4949 case 3:
5050 ApplyMigration(db, "003-fail-lock")
5151 oldDBVersion = 4
5252-5353- case 4:
5454- ApplyMigration(db, "004-test")
5555- oldDBVersion = 5
56525753 }
5854 }
-1
controller/schema-migration/004-test.sql
···11-INSERT INTO arimelody.auditlog (level, type, content) VALUES (0, "test", "this is a db schema migration test!");