gosora/database.go
Azareal fdb6304e32 Mostly a mid-way technical commit to make reading diffs easier on me.
Split the relativeTime function into relativeTime and relativeTimeFromString.
Refactored the installer.
Made a lot of progress with PgSQL and MSSQL support, mostly MSSQL.
Made a lot of progress on the automated testing suite.
Added eqcss to the file extension list.
..depressed..
Fixed various bugs here and there.
gen_mysql.go is now properly excluded when the pgsql or mssql build tag is passed.
The BBCode plugin is now always initialised prior to it's test.
We've begun transitioning towards deserializing database times directly into time.Times rather than doing it every time on the spot.
Added more dev flags.
The tests now make use of a test database rather than the production database.
2017-10-14 08:39:22 +01:00

68 lines
1.4 KiB
Go

package main
import "log"
import "database/sql"
var db *sql.DB
var dbVersion string
var dbAdapter string
// ErrNoRows is an alias of sql.ErrNoRows, just in case we end up with non-database/sql datastores
var ErrNoRows = sql.ErrNoRows
var _initDatabase func() error
func initDatabase() (err error) {
// Engine specific code
err = _initDatabase()
if err != nil {
return err
}
log.Print("Loading the usergroups.")
gstore = NewMemoryGroupStore()
err = gstore.LoadGroups()
if err != nil {
return err
}
// We have to put this here, otherwise LoadForums() won't be able to get the last poster data when building it's forums
log.Print("Initialising the user and topic stores")
if config.CacheTopicUser == CACHE_STATIC {
users = NewMemoryUserStore(config.UserCacheCapacity)
topics = NewMemoryTopicStore(config.TopicCacheCapacity)
} else {
users = NewSQLUserStore()
topics = NewSQLTopicStore()
}
log.Print("Loading the forums.")
fstore = NewMemoryForumStore()
err = fstore.LoadForums()
if err != nil {
return err
}
log.Print("Loading the forum permissions.")
err = buildForumPermissions()
if err != nil {
return err
}
log.Print("Loading the settings.")
err = LoadSettings()
if err != nil {
return err
}
log.Print("Loading the plugins.")
err = initExtend()
if err != nil {
return err
}
log.Print("Loading the themes.")
return LoadThemes()
}