mirror of
https://github.com/gofiber/storage.git
synced 2025-10-28 02:31:26 +08:00
Revert DisableStartupCheck changes for select drivers
This commit is contained in:
@@ -63,26 +63,28 @@ func New(config ...Config) *Storage {
|
||||
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
||||
}
|
||||
|
||||
// Ping database to ensure a connection has been made
|
||||
if err := db.Ping(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Drop table if Clear set to true
|
||||
if cfg.Reset {
|
||||
query := fmt.Sprintf(dropQuery, cfg.Table)
|
||||
if _, err = db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
if !cfg.DisableStartupCheck {
|
||||
// Ping database to ensure a connection has been made
|
||||
if err := db.Ping(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Init database queries
|
||||
for _, query := range initQuery {
|
||||
query = fmt.Sprintf(query, cfg.Table)
|
||||
if _, err := db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
// Drop table if Clear set to true
|
||||
if cfg.Reset {
|
||||
query := fmt.Sprintf(dropQuery, cfg.Table)
|
||||
if _, err = db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Init database queries
|
||||
for _, query := range initQuery {
|
||||
query = fmt.Sprintf(query, cfg.Table)
|
||||
if _, err := db.Exec(query); err != nil {
|
||||
_ = db.Close()
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +100,9 @@ func New(config ...Config) *Storage {
|
||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= ? AND e != 0", cfg.Table),
|
||||
}
|
||||
|
||||
store.checkSchema(cfg.Table)
|
||||
if !cfg.DisableStartupCheck {
|
||||
store.checkSchema(cfg.Table)
|
||||
}
|
||||
|
||||
// Start garbage collector
|
||||
go store.gcTicker()
|
||||
|
||||
Reference in New Issue
Block a user