91f70d2a4a
Added basic support for server sync. Re-added a few missing defers. Renamed TO-DO to TODO across the entire codebase. Renamed StaticForumStore to MemoryForumStore. The ForumStore is now built on a sync.Map with a view slice for generating /forums rather than a slice. Renamed many more functions and variables to satisfy the linter. increase_post_user_stats() and decrease_post_user_stats() are now methods on the User struct. We also fix a bug where they take the moderator's score rather than the target user's into account when recalculating their level after a post / topic is deleted. Transitioned the topic list to CSS Grid for Tempra Simple, with a float fallback. Cosmo and Cosmo Conflux are now hidden from the theme list. Fixed more data races. Added more debug data to the template compiler logs.
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
/* WIP Under Construction */
|
|
package qgen
|
|
|
|
var Install *installer
|
|
|
|
func init() {
|
|
Install = &installer{instructions: []DB_Install_Instruction{}}
|
|
}
|
|
|
|
type DB_Install_Instruction struct {
|
|
Table string
|
|
Contents string
|
|
Type string
|
|
}
|
|
|
|
// A set of wrappers around the generator methods, so we can use this in the installer
|
|
// TODO: Re-implement the query generation, query builder and installer adapters as layers on-top of a query text adapter
|
|
type installer struct {
|
|
adapter DB_Adapter
|
|
instructions []DB_Install_Instruction
|
|
}
|
|
|
|
func (install *installer) SetAdapter(name string) error {
|
|
adap, err := GetAdapter(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
install.adapter = adap
|
|
return nil
|
|
}
|
|
|
|
func (install *installer) SetAdapterInstance(adapter DB_Adapter) {
|
|
install.adapter = adapter
|
|
}
|
|
|
|
func (install *installer) CreateTable(table string, charset string, collation string, columns []DB_Table_Column, keys []DB_Table_Key) error {
|
|
res, err := install.adapter.CreateTable("_installer", table, charset, collation, columns, keys)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
install.instructions = append(install.instructions, DB_Install_Instruction{table, res, "create-table"})
|
|
return nil
|
|
}
|
|
|
|
func (install *installer) Write() error {
|
|
var inserts string
|
|
// We can't escape backticks, so we have to dump it out a file at a time
|
|
for _, instr := range install.instructions {
|
|
if instr.Type == "create-table" {
|
|
err := writeFile("./schema/"+install.adapter.GetName()+"/query_"+instr.Table+".sql", instr.Contents)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
inserts += instr.Contents + "\n"
|
|
}
|
|
}
|
|
return writeFile("./schema/"+install.adapter.GetName()+"/inserts.sql", inserts)
|
|
}
|