Optimise template generator.
Optimise mysql adapter. Add TokenScope to mysql adapter. Add SimpleBulkInsert() to installer. Optimise panel.Plugins() route.
This commit is contained in:
parent
39ace845b7
commit
78fbbcda21
|
@ -78,6 +78,8 @@ type CTemplateSet struct {
|
|||
logger *log.Logger
|
||||
loggerf *os.File
|
||||
lang string
|
||||
|
||||
fsb strings.Builder
|
||||
}
|
||||
|
||||
func NewCTemplateSet(in string, logDir ...string) *CTemplateSet {
|
||||
|
@ -446,20 +448,6 @@ func (c *CTemplateSet) compile(name, content, expects string, expectsInt interfa
|
|||
importList += "import \"" + item + "\"\n"
|
||||
}
|
||||
}
|
||||
//var varString string
|
||||
var vssb strings.Builder
|
||||
vssb.Grow(10 + 3)
|
||||
for _, varItem := range c.varList {
|
||||
//varString += "var " + varItem.Name + " " + varItem.Type + " = " + varItem.Destination + "\n"
|
||||
vssb.WriteString("var ")
|
||||
vssb.WriteString(varItem.Name)
|
||||
vssb.WriteRune(' ')
|
||||
vssb.WriteString(varItem.Type)
|
||||
vssb.WriteString(" = ")
|
||||
vssb.WriteString(varItem.Destination)
|
||||
vssb.WriteString("\n")
|
||||
}
|
||||
varString := vssb.String()
|
||||
|
||||
var fout string
|
||||
if c.buildTags != "" {
|
||||
|
@ -537,19 +525,27 @@ func (c *CTemplateSet) compile(name, content, expects string, expectsInt interfa
|
|||
fout += "}\n\n"
|
||||
}
|
||||
|
||||
c.fsb.Reset()
|
||||
c.fsb.WriteString("// nolint\nfunc Tmpl_")
|
||||
c.fsb.WriteString(fname)
|
||||
if c.lang == "normal" {
|
||||
fout += "// nolint\nfunc Tmpl_" + fname + "(tmpl_i interface{}, w io.Writer) error {\n"
|
||||
/*fout += "// nolint\nfunc Tmpl_" + fname + "(tmpl_i interface{}, w io.Writer) error {\n"
|
||||
fout += `tmpl_` + fname + `_vars, ok := tmpl_i.(` + expects + `)
|
||||
if !ok {
|
||||
return errors.New("invalid page struct value")
|
||||
}
|
||||
`
|
||||
/*fout += `tmpl_vars, ok := tmpl_i.(` + expects + `)
|
||||
if !ok {
|
||||
return errors.New("invalid page struct value")
|
||||
}
|
||||
`*/
|
||||
fout += `var iw http.ResponseWriter
|
||||
c.fsb.WriteString("(tmpl_i interface{}, w io.Writer) error {\n")
|
||||
|
||||
c.fsb.WriteString(`tmpl_`)
|
||||
c.fsb.WriteString(fname)
|
||||
c.fsb.WriteString(`_vars, ok := tmpl_i.(`)
|
||||
c.fsb.WriteString(expects)
|
||||
c.fsb.WriteString(`)
|
||||
if !ok {
|
||||
return errors.New("invalid page struct value")
|
||||
}
|
||||
var iw http.ResponseWriter
|
||||
if gzw, ok := w.(c.GzipResponseWriter); ok {
|
||||
iw = gzw.ResponseWriter
|
||||
w = gzw.Writer
|
||||
|
@ -557,19 +553,41 @@ if !ok {
|
|||
_ = iw
|
||||
var tmp []byte
|
||||
_ = tmp
|
||||
`
|
||||
`)
|
||||
} else {
|
||||
fout += "// nolint\nfunc Tmpl_" + fname + "(tmpl_" + fname + "_vars interface{}, w io.Writer) error {\n"
|
||||
//fout += "// nolint\nfunc Tmpl_" + fname + "(tmpl_" + fname + "_vars interface{}, w io.Writer) error {\n"
|
||||
c.fsb.WriteString("(tmpl_")
|
||||
c.fsb.WriteString(fname)
|
||||
c.fsb.WriteString("_vars interface{}, w io.Writer) error {\n")
|
||||
//fout += "// nolint\nfunc Tmpl_" + fname + "(tmpl_vars interface{}, w io.Writer) error {\n"
|
||||
}
|
||||
|
||||
//var fsb strings.Builder
|
||||
if len(c.langIndexToName) > 0 {
|
||||
fout += "//var plist = phrases.GetTmplPhrasesBytes(" + fname + "_tmpl_phrase_id)\n"
|
||||
//fout += "//var plist = phrases.GetTmplPhrasesBytes(" + fname + "_tmpl_phrase_id)\n"
|
||||
c.fsb.WriteString("//var plist = phrases.GetTmplPhrasesBytes(")
|
||||
c.fsb.WriteString(fname)
|
||||
c.fsb.WriteString("_tmpl_phrase_id)\n")
|
||||
|
||||
//fout += "if len(plist) > 0 {\n_ = plist[len(plist)-1]\n}\n"
|
||||
//fout += "var plist = " + fname + "_phrase_arr\n"
|
||||
}
|
||||
var fsb strings.Builder
|
||||
fsb.WriteString(varString)
|
||||
|
||||
//var varString string
|
||||
//var vssb strings.Builder
|
||||
c.fsb.Grow(10 + 3)
|
||||
for _, varItem := range c.varList {
|
||||
//varString += "var " + varItem.Name + " " + varItem.Type + " = " + varItem.Destination + "\n"
|
||||
c.fsb.WriteString("var ")
|
||||
c.fsb.WriteString(varItem.Name)
|
||||
c.fsb.WriteRune(' ')
|
||||
c.fsb.WriteString(varItem.Type)
|
||||
c.fsb.WriteString(" = ")
|
||||
c.fsb.WriteString(varItem.Destination)
|
||||
c.fsb.WriteString("\n")
|
||||
}
|
||||
|
||||
//c.fsb.WriteString(varString)
|
||||
//fout += varString
|
||||
skipped := make(map[string]*SkipBlock) // map[templateName]*SkipBlock{map[atIndexAndAfter]skipThisMuch,lastCount}
|
||||
|
||||
|
@ -577,7 +595,7 @@ if !ok {
|
|||
out := "w.Write(" + tmplName + "_frags[" + strconv.Itoa(index) + "]" + ")\n"
|
||||
c.detail("writing ", out)
|
||||
//fout += out
|
||||
fsb.WriteString(out)
|
||||
c.fsb.WriteString(out)
|
||||
}
|
||||
|
||||
for fid := 0; len(outBuf) > fid; fid++ {
|
||||
|
@ -613,31 +631,31 @@ if !ok {
|
|||
writeTextFrame(fr.TemplateName, fr.Extra.(int)-skip)
|
||||
case fr.Type == "varsub" || fr.Type == "cvarsub":
|
||||
//fout += "w.Write(" + fr.Body + ")\n"
|
||||
fsb.WriteString("w.Write(")
|
||||
fsb.WriteString(fr.Body)
|
||||
fsb.WriteString(")\n")
|
||||
c.fsb.WriteString("w.Write(")
|
||||
c.fsb.WriteString(fr.Body)
|
||||
c.fsb.WriteString(")\n")
|
||||
case fr.Type == "lang":
|
||||
//fout += "w.Write(plist[" + strconv.Itoa(fr.Extra.(int)) + "])\n"
|
||||
fsb.WriteString("w.Write(")
|
||||
fsb.WriteString(fname)
|
||||
c.fsb.WriteString("w.Write(")
|
||||
c.fsb.WriteString(fname)
|
||||
if len(c.langIndexToName) == 1 {
|
||||
//fout += "w.Write(" + fname + "_phrase)\n"
|
||||
fsb.WriteString("_phrase)\n")
|
||||
c.fsb.WriteString("_phrase)\n")
|
||||
} else {
|
||||
//fout += "w.Write(" + fname + "_phrase_arr[" + strconv.Itoa(fr.Extra.(int)) + "])\n"
|
||||
fsb.WriteString("_phrase_arr[")
|
||||
fsb.WriteString(strconv.Itoa(fr.Extra.(int)))
|
||||
fsb.WriteString("])\n")
|
||||
c.fsb.WriteString("_phrase_arr[")
|
||||
c.fsb.WriteString(strconv.Itoa(fr.Extra.(int)))
|
||||
c.fsb.WriteString("])\n")
|
||||
}
|
||||
//case fr.Type == "identifier":
|
||||
default:
|
||||
//fout += fr.Body
|
||||
fsb.WriteString(fr.Body)
|
||||
c.fsb.WriteString(fr.Body)
|
||||
}
|
||||
}
|
||||
//fout += "return nil\n}\n"
|
||||
fsb.WriteString("return nil\n}\n")
|
||||
fout += fsb.String()
|
||||
c.fsb.WriteString("return nil\n}\n")
|
||||
fout += c.fsb.String()
|
||||
|
||||
writeFrag := func(tmplName string, index int, body string) {
|
||||
//c.detail("writing ", fragmentPrefix)
|
||||
|
@ -2163,8 +2181,7 @@ func (c *CTemplateSet) afterTemplateV2(con CContext, startIndex int /*, typ int*
|
|||
c.dumpCall("afterTemplateV2", con, startIndex)
|
||||
defer c.retCall("afterTemplateV2")
|
||||
|
||||
loopDepth := 0
|
||||
ifNilDepth := 0
|
||||
loopDepth, ifNilDepth := 0, 0
|
||||
var outBuf = *con.OutBuf
|
||||
varcounts := make(map[string]int)
|
||||
loopStart := startIndex
|
||||
|
@ -2228,8 +2245,7 @@ OLoop:
|
|||
}
|
||||
|
||||
// Exclude varsubs within loops for now
|
||||
loopDepth = 0
|
||||
ifNilDepth = 0
|
||||
loopDepth, ifNilDepth = 0, 0
|
||||
OOLoop:
|
||||
for i := loopStart; i < len(outBuf); i++ {
|
||||
item := outBuf[i]
|
||||
|
|
|
@ -31,16 +31,16 @@ type installer struct {
|
|||
}
|
||||
|
||||
func (i *installer) SetAdapter(name string) error {
|
||||
adap, err := GetAdapter(name)
|
||||
a, err := GetAdapter(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i.SetAdapterInstance(adap)
|
||||
i.SetAdapterInstance(a)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *installer) SetAdapterInstance(adap Adapter) {
|
||||
i.adapter = adap
|
||||
func (i *installer) SetAdapterInstance(a Adapter) {
|
||||
i.adapter = a
|
||||
i.instructions = []DBInstallInstruction{}
|
||||
}
|
||||
|
||||
|
@ -48,13 +48,13 @@ func (i *installer) AddPlugins(plugins ...QueryPlugin) {
|
|||
i.plugins = append(i.plugins, plugins...)
|
||||
}
|
||||
|
||||
func (i *installer) CreateTable(table, charset, collation string, columns []DBTableColumn, keys []DBTableKey) error {
|
||||
tableStruct := &DBInstallTable{table, charset, collation, columns, keys}
|
||||
func (i *installer) CreateTable(table, charset, collation string, cols []DBTableColumn, keys []DBTableKey) error {
|
||||
tableStruct := &DBInstallTable{table, charset, collation, cols, keys}
|
||||
err := i.RunHook("CreateTableStart", tableStruct)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := i.adapter.CreateTable("", table, charset, collation, columns, keys)
|
||||
res, err := i.adapter.CreateTable("", table, charset, collation, cols, keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -68,16 +68,16 @@ func (i *installer) CreateTable(table, charset, collation string, columns []DBTa
|
|||
}
|
||||
|
||||
// TODO: Let plugins manipulate the parameters like in CreateTable
|
||||
func (i *installer) AddIndex(table, iname, colname string) error {
|
||||
err := i.RunHook("AddIndexStart", table, iname, colname)
|
||||
func (i *installer) AddIndex(table, iname, colName string) error {
|
||||
err := i.RunHook("AddIndexStart", table, iname, colName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := i.adapter.AddIndex("", table, iname, colname)
|
||||
res, err := i.adapter.AddIndex("", table, iname, colName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = i.RunHook("AddIndexAfter", table, iname, colname)
|
||||
err = i.RunHook("AddIndexAfter", table, iname, colName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -85,16 +85,16 @@ func (i *installer) AddIndex(table, iname, colname string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *installer) AddKey(table, column string, key DBTableKey) error {
|
||||
err := i.RunHook("AddKeyStart", table, column, key)
|
||||
func (i *installer) AddKey(table, col string, key DBTableKey) error {
|
||||
err := i.RunHook("AddKeyStart", table, col, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := i.adapter.AddKey("", table, column, key)
|
||||
res, err := i.adapter.AddKey("", table, col, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = i.RunHook("AddKeyAfter", table, column, key)
|
||||
err = i.RunHook("AddKeyAfter", table, col, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -120,9 +120,26 @@ func (i *installer) SimpleInsert(table, columns, fields string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (i *installer) SimpleBulkInsert(table, cols string, fieldSet []string) error {
|
||||
err := i.RunHook("SimpleBulkInsertStart", table, cols, fieldSet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := i.adapter.SimpleBulkInsert("", table, cols, fieldSet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = i.RunHook("SimpleBulkInsertAfter", table, cols, fieldSet, res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i.instructions = append(i.instructions, DBInstallInstruction{table, res, "bulk-insert"})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *installer) RunHook(name string, args ...interface{}) error {
|
||||
for _, plugin := range i.plugins {
|
||||
err := plugin.Hook(name, args...)
|
||||
for _, pl := range i.plugins {
|
||||
err := pl.Hook(name, args...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -94,57 +94,109 @@ func (a *MysqlAdapter) DropTable(name, table string) (string, error) {
|
|||
return q, nil
|
||||
}
|
||||
|
||||
func (a *MysqlAdapter) CreateTable(name, table, charset, collation string, columns []DBTableColumn, keys []DBTableKey) (string, error) {
|
||||
func (a *MysqlAdapter) CreateTable(name, table, charset, collation string, cols []DBTableColumn, keys []DBTableKey) (string, error) {
|
||||
if table == "" {
|
||||
return "", errors.New("You need a name for this table")
|
||||
}
|
||||
if len(columns) == 0 {
|
||||
if len(cols) == 0 {
|
||||
return "", errors.New("You can't have a table with no columns")
|
||||
}
|
||||
|
||||
q := "CREATE TABLE `" + table + "` ("
|
||||
for _, column := range columns {
|
||||
column, size, end := a.parseColumn(column)
|
||||
q += "\n\t`" + column.Name + "` " + column.Type + size + end + ","
|
||||
var qsb strings.Builder
|
||||
//q := "CREATE TABLE `" + table + "`("
|
||||
w := func(s string) {
|
||||
qsb.WriteString(s)
|
||||
}
|
||||
w("CREATE TABLE `")
|
||||
w(table)
|
||||
w("`(")
|
||||
for i, col := range cols {
|
||||
if i != 0 {
|
||||
w(",\n\t`")
|
||||
} else {
|
||||
w("\n\t`")
|
||||
}
|
||||
col, size, end := a.parseColumn(col)
|
||||
//q += "\n\t`" + col.Name + "` " + col.Type + size + end + ","
|
||||
w(col.Name)
|
||||
w("` ")
|
||||
w(col.Type)
|
||||
w(size)
|
||||
w(end)
|
||||
}
|
||||
|
||||
if len(keys) > 0 {
|
||||
for _, key := range keys {
|
||||
q += "\n\t" + key.Type
|
||||
if key.Type != "unique" {
|
||||
q += " key"
|
||||
}
|
||||
if key.Type == "foreign" {
|
||||
cols := strings.Split(key.Columns, ",")
|
||||
q += "(`" + cols[0] + "`) REFERENCES `" + key.FTable + "`(`" + cols[1] + "`)"
|
||||
if key.Cascade {
|
||||
q += " ON DELETE CASCADE"
|
||||
}
|
||||
q += ","
|
||||
/*if len(cols) > 0 {
|
||||
w(",")
|
||||
}*/
|
||||
for _, k := range keys {
|
||||
/*if ii != 0 {
|
||||
w(",\n\t")
|
||||
} else {
|
||||
q += "("
|
||||
for i, column := range strings.Split(key.Columns, ",") {
|
||||
w("\n\t")
|
||||
}*/
|
||||
w(",\n\t")
|
||||
//q += "\n\t" + key.Type
|
||||
w(k.Type)
|
||||
if k.Type != "unique" {
|
||||
//q += " key"
|
||||
w(" key")
|
||||
}
|
||||
if k.Type == "foreign" {
|
||||
cols := strings.Split(k.Columns, ",")
|
||||
//q += "(`" + cols[0] + "`) REFERENCES `" + k.FTable + "`(`" + cols[1] + "`)"
|
||||
w("(`")
|
||||
w(cols[0])
|
||||
w("`) REFERENCES `")
|
||||
w(k.FTable)
|
||||
w("`(`")
|
||||
w(cols[1])
|
||||
w("`)")
|
||||
if k.Cascade {
|
||||
//q += " ON DELETE CASCADE"
|
||||
w(" ON DELETE CASCADE")
|
||||
}
|
||||
//q += ","
|
||||
} else {
|
||||
//q += "("
|
||||
w("(")
|
||||
for i, col := range strings.Split(k.Columns, ",") {
|
||||
/*if i != 0 {
|
||||
q += ",`" + col + "`"
|
||||
} else {
|
||||
q += "`" + col + "`"
|
||||
}*/
|
||||
if i != 0 {
|
||||
q += ",`" + column + "`"
|
||||
w(",`")
|
||||
} else {
|
||||
q += "`" + column + "`"
|
||||
w("`")
|
||||
}
|
||||
w(col)
|
||||
w("`")
|
||||
}
|
||||
q += "),"
|
||||
//q += "),"
|
||||
w(")")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
q = q[0:len(q)-1] + "\n)"
|
||||
//q = q[0:len(q)-1] + "\n)"
|
||||
w("\n)")
|
||||
if charset != "" {
|
||||
q += " CHARSET=" + charset
|
||||
//q += " CHARSET=" + charset
|
||||
w(" CHARSET=")
|
||||
w(charset)
|
||||
}
|
||||
if collation != "" {
|
||||
q += " COLLATE " + collation
|
||||
//q += " COLLATE " + collation
|
||||
w(" COLLATE ")
|
||||
w(collation)
|
||||
}
|
||||
|
||||
// TODO: Shunt the table name logic and associated stmt list up to the a higher layer to reduce the amount of unnecessary overhead in the builder / accumulator
|
||||
q += ";"
|
||||
//q += ";"
|
||||
w(";")
|
||||
q := qsb.String()
|
||||
a.pushStatement(name, "create-table", q)
|
||||
return q, nil
|
||||
}
|
||||
|
@ -312,7 +364,7 @@ func (a *MysqlAdapter) RemoveIndex(name, table, iname string) (string, error) {
|
|||
return q, nil
|
||||
}
|
||||
|
||||
func (a *MysqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string, cascade bool) (out string, e error) {
|
||||
func (a *MysqlAdapter) AddForeignKey(name, table, col, ftable, fcolumn string, cascade bool) (out string, e error) {
|
||||
c := func(str string, val bool) {
|
||||
if e != nil || !val {
|
||||
return
|
||||
|
@ -320,14 +372,14 @@ func (a *MysqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string
|
|||
e = errors.New("You need a " + str + " for this table")
|
||||
}
|
||||
c("name", table == "")
|
||||
c("column", column == "")
|
||||
c("col", col == "")
|
||||
c("ftable", ftable == "")
|
||||
c("fcolumn", fcolumn == "")
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
q := "ALTER TABLE `" + table + "` ADD CONSTRAINT `fk_" + column + "` FOREIGN KEY(`" + column + "`) REFERENCES `" + ftable + "`(`" + fcolumn + "`)"
|
||||
q := "ALTER TABLE `" + table + "` ADD CONSTRAINT `fk_" + col + "` FOREIGN KEY(`" + col + "`) REFERENCES `" + ftable + "`(`" + fcolumn + "`)"
|
||||
if cascade {
|
||||
q += " ON DELETE CASCADE"
|
||||
}
|
||||
|
@ -337,9 +389,9 @@ func (a *MysqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string
|
|||
return q, nil
|
||||
}
|
||||
|
||||
const silen1 = len("INSERT INTO ``() VALUES () ")
|
||||
const silen1 = len("INSERT INTO``()VALUES() ")
|
||||
|
||||
func (a *MysqlAdapter) SimpleInsert(name, table, columns, fields string) (string, error) {
|
||||
func (a *MysqlAdapter) SimpleInsert(name, table, cols, fields string) (string, error) {
|
||||
if table == "" {
|
||||
return "", errors.New("You need a name for this table")
|
||||
}
|
||||
|
@ -354,12 +406,12 @@ func (a *MysqlAdapter) SimpleInsert(name, table, columns, fields string) (string
|
|||
}
|
||||
|
||||
sb.Grow(silen1 + len(table))
|
||||
sb.WriteString("INSERT INTO `")
|
||||
sb.WriteString("INSERT INTO`")
|
||||
sb.WriteString(table)
|
||||
if columns != "" {
|
||||
if cols != "" {
|
||||
sb.WriteString("`(")
|
||||
sb.WriteString(a.buildColumns(columns))
|
||||
sb.WriteString(") VALUES (")
|
||||
sb.WriteString(a.buildColumns(cols))
|
||||
sb.WriteString(")VALUES(")
|
||||
fs := processFields(fields)
|
||||
sb.Grow(len(fs) * 3)
|
||||
for i, field := range fs {
|
||||
|
@ -381,7 +433,7 @@ func (a *MysqlAdapter) SimpleInsert(name, table, columns, fields string) (string
|
|||
}
|
||||
sb.WriteString(")")
|
||||
} else {
|
||||
sb.WriteString("`() VALUES ()")
|
||||
sb.WriteString("`()VALUES()")
|
||||
}
|
||||
|
||||
// TODO: Shunt the table name logic and associated stmt list up to the a higher layer to reduce the amount of unnecessary overhead in the builder / accumulator
|
||||
|
@ -391,7 +443,7 @@ func (a *MysqlAdapter) SimpleInsert(name, table, columns, fields string) (string
|
|||
return q, nil
|
||||
}
|
||||
|
||||
func (a *MysqlAdapter) SimpleBulkInsert(name, table, columns string, fieldSet []string) (string, error) {
|
||||
func (a *MysqlAdapter) SimpleBulkInsert(name, table, cols string, fieldSet []string) (string, error) {
|
||||
if table == "" {
|
||||
return "", errors.New("You need a name for this table")
|
||||
}
|
||||
|
@ -405,12 +457,12 @@ func (a *MysqlAdapter) SimpleBulkInsert(name, table, columns string, fieldSet []
|
|||
sb.Reset()
|
||||
}
|
||||
sb.Grow(silen1 + len(table))
|
||||
sb.WriteString("INSERT INTO `")
|
||||
sb.WriteString("INSERT INTO`")
|
||||
sb.WriteString(table)
|
||||
if columns != "" {
|
||||
if cols != "" {
|
||||
sb.WriteString("`(")
|
||||
sb.WriteString(a.buildColumns(columns))
|
||||
sb.WriteString(") VALUES (")
|
||||
sb.WriteString(a.buildColumns(cols))
|
||||
sb.WriteString(")VALUES(")
|
||||
for oi, fields := range fieldSet {
|
||||
if oi != 0 {
|
||||
sb.WriteString(",(")
|
||||
|
@ -423,17 +475,25 @@ func (a *MysqlAdapter) SimpleBulkInsert(name, table, columns string, fieldSet []
|
|||
}
|
||||
nameLen := len(field.Name)
|
||||
if field.Name[0] == '"' && field.Name[nameLen-1] == '"' && nameLen >= 3 {
|
||||
field.Name = "'" + field.Name[1:nameLen-1] + "'"
|
||||
//field.Name = "'" + field.Name[1:nameLen-1] + "'"
|
||||
sb.WriteString("'")
|
||||
sb.WriteString(field.Name[1 : nameLen-1])
|
||||
sb.WriteString("'")
|
||||
continue
|
||||
}
|
||||
if field.Name[0] == '\'' && field.Name[nameLen-1] == '\'' && nameLen >= 3 {
|
||||
field.Name = "'" + strings.Replace(field.Name[1:nameLen-1], "'", "''", -1) + "'"
|
||||
//field.Name = "'" + strings.Replace(field.Name[1:nameLen-1], "'", "''", -1) + "'"
|
||||
sb.WriteString("'")
|
||||
sb.WriteString(strings.Replace(field.Name[1:nameLen-1], "'", "''", -1))
|
||||
sb.WriteString("'")
|
||||
continue
|
||||
}
|
||||
sb.WriteString(field.Name)
|
||||
}
|
||||
sb.WriteString(")")
|
||||
}
|
||||
} else {
|
||||
sb.WriteString("`() VALUES ()")
|
||||
sb.WriteString("`()VALUES()")
|
||||
}
|
||||
|
||||
// TODO: Shunt the table name logic and associated stmt list up to the a higher layer to reduce the amount of unnecessary overhead in the builder / accumulator
|
||||
|
@ -443,34 +503,62 @@ func (a *MysqlAdapter) SimpleBulkInsert(name, table, columns string, fieldSet []
|
|||
return q, nil
|
||||
}
|
||||
|
||||
func (a *MysqlAdapter) buildColumns(columns string) (q string) {
|
||||
if columns == "" {
|
||||
func (a *MysqlAdapter) buildColumns(cols string) string {
|
||||
if cols == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Escape the column names, just in case we've used a reserved keyword
|
||||
for _, col := range processColumns(columns) {
|
||||
var cb strings.Builder
|
||||
pcols := processColumns(cols)
|
||||
var n int
|
||||
for i, col := range pcols {
|
||||
if i != 0 {
|
||||
n += 1
|
||||
}
|
||||
if col.Type == TokenFunc {
|
||||
q += col.Left + ","
|
||||
n += len(col.Left)
|
||||
} else {
|
||||
q += "`" + col.Left + "`,"
|
||||
n += len(col.Left) + 2
|
||||
}
|
||||
}
|
||||
return q[0 : len(q)-1]
|
||||
cb.Grow(n)
|
||||
|
||||
for i, col := range pcols {
|
||||
if col.Type == TokenFunc {
|
||||
if i != 0 {
|
||||
cb.WriteString(",")
|
||||
}
|
||||
//q += col.Left + ","
|
||||
cb.WriteString(col.Left)
|
||||
} else {
|
||||
//q += "`" + col.Left + "`,"
|
||||
if i != 0 {
|
||||
cb.WriteString(",`")
|
||||
} else {
|
||||
cb.WriteString("`")
|
||||
}
|
||||
cb.WriteString(col.Left)
|
||||
cb.WriteString("`")
|
||||
}
|
||||
}
|
||||
|
||||
return cb.String()
|
||||
}
|
||||
|
||||
// ! DEPRECATED
|
||||
func (a *MysqlAdapter) SimpleReplace(name, table, columns, fields string) (string, error) {
|
||||
func (a *MysqlAdapter) SimpleReplace(name, table, cols, fields string) (string, error) {
|
||||
if table == "" {
|
||||
return "", errors.New("You need a name for this table")
|
||||
}
|
||||
if len(columns) == 0 {
|
||||
if len(cols) == 0 {
|
||||
return "", errors.New("No columns found for SimpleInsert")
|
||||
}
|
||||
if len(fields) == 0 {
|
||||
return "", errors.New("No input data found for SimpleInsert")
|
||||
}
|
||||
|
||||
q := "REPLACE INTO `" + table + "`(" + a.buildColumns(columns) + ") VALUES ("
|
||||
q := "REPLACE INTO `" + table + "`(" + a.buildColumns(cols) + ") VALUES ("
|
||||
for _, field := range processFields(fields) {
|
||||
q += field.Name + ","
|
||||
}
|
||||
|
@ -575,9 +663,9 @@ func (a *MysqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
err := a.buildFlexiWhereSb(sb, up.where, up.dateCutoff)
|
||||
if err != nil {
|
||||
return sb.String(), err
|
||||
e := a.buildFlexiWhereSb(sb, up.where, up.dateCutoff)
|
||||
if e != nil {
|
||||
return sb.String(), e
|
||||
}
|
||||
|
||||
// TODO: Shunt the table name logic and associated stmt list up to the a higher layer to reduce the amount of unnecessary overhead in the builder / accumulator
|
||||
|
@ -662,9 +750,9 @@ func (a *MysqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error) {
|
|||
sb.WriteString(b.table)
|
||||
sb.WriteRune('`')
|
||||
|
||||
err := a.buildFlexiWhereSb(sb, b.where, b.dateCutoff)
|
||||
if err != nil {
|
||||
return sb.String(), err
|
||||
e := a.buildFlexiWhereSb(sb, b.where, b.dateCutoff)
|
||||
if e != nil {
|
||||
return sb.String(), e
|
||||
}
|
||||
q := sb.String()
|
||||
queryStrPool.Put(sb)
|
||||
|
@ -748,7 +836,6 @@ func (a *MysqlAdapter) buildFlexiWhere(where string, dateCutoff *dateCutoff) (q
|
|||
sb.WriteString(dateCutoff.Unit)
|
||||
}
|
||||
}
|
||||
|
||||
if dateCutoff != nil && len(where) != 0 {
|
||||
sb.WriteString(" AND")
|
||||
}
|
||||
|
@ -809,7 +896,6 @@ func (a *MysqlAdapter) buildFlexiWhereSb(sb *strings.Builder, where string, date
|
|||
sb.WriteString(dateCutoff.Unit)
|
||||
}
|
||||
}
|
||||
|
||||
if dateCutoff != nil && len(where) != 0 {
|
||||
sb.WriteString(" AND")
|
||||
}
|
||||
|
@ -911,7 +997,7 @@ func (a *MysqlAdapter) SimpleSelect(name, table, cols, where, orderby, limit str
|
|||
sb.WriteString(strings.TrimSpace(col))
|
||||
}
|
||||
|
||||
sb.WriteString("` FROM `")
|
||||
sb.WriteString("`FROM`")
|
||||
sb.WriteString(table)
|
||||
sb.WriteRune('`')
|
||||
err := a.buildWhere(where, sb)
|
||||
|
@ -927,7 +1013,7 @@ func (a *MysqlAdapter) SimpleSelect(name, table, cols, where, orderby, limit str
|
|||
return q, nil
|
||||
}
|
||||
|
||||
func (a *MysqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (out string, err error) {
|
||||
func (a *MysqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (out string, e error) {
|
||||
var sb *strings.Builder
|
||||
ii := queryStrPool.Get()
|
||||
if ii == nil {
|
||||
|
@ -936,15 +1022,15 @@ func (a *MysqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (out string,
|
|||
sb = ii.(*strings.Builder)
|
||||
sb.Reset()
|
||||
}
|
||||
err = a.complexSelect(preBuilder, sb)
|
||||
e = a.complexSelect(preBuilder, sb)
|
||||
out = sb.String()
|
||||
queryStrPool.Put(sb)
|
||||
a.pushStatement(preBuilder.name, "select", out)
|
||||
return out, err
|
||||
return out, e
|
||||
}
|
||||
|
||||
const cslen1 = len("SELECT FROM ``")
|
||||
const cslen2 = len(" WHERE `` IN(")
|
||||
const cslen2 = len("WHERE``IN(")
|
||||
|
||||
func (a *MysqlAdapter) complexSelect(preBuilder *selectPrebuilder, sb *strings.Builder) error {
|
||||
if preBuilder.table == "" {
|
||||
|
@ -965,18 +1051,18 @@ func (a *MysqlAdapter) complexSelect(preBuilder *selectPrebuilder, sb *strings.B
|
|||
// TODO: Let callers have a Where() and a InQ()
|
||||
if preBuilder.inChain != nil {
|
||||
sb.Grow(cslen2 + len(preBuilder.inColumn))
|
||||
sb.WriteString(" WHERE `")
|
||||
sb.WriteString("WHERE`")
|
||||
sb.WriteString(preBuilder.inColumn)
|
||||
sb.WriteString("` IN(")
|
||||
err := a.complexSelect(preBuilder.inChain, sb)
|
||||
if err != nil {
|
||||
return err
|
||||
sb.WriteString("`IN(")
|
||||
e := a.complexSelect(preBuilder.inChain, sb)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
sb.WriteRune(')')
|
||||
} else {
|
||||
err := a.buildFlexiWhereSb(sb, preBuilder.where, preBuilder.dateCutoff)
|
||||
if err != nil {
|
||||
return err
|
||||
e := a.buildFlexiWhereSb(sb, preBuilder.where, preBuilder.dateCutoff)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1092,9 +1178,9 @@ func (a *MysqlAdapter) SimpleUpdateSelect(up *updatePrebuilder) (string, error)
|
|||
|
||||
func (a *MysqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error) {
|
||||
sb := &strings.Builder{}
|
||||
err := a.buildWhere(sel.Where, sb)
|
||||
if err != nil {
|
||||
return "", err
|
||||
e := a.buildWhere(sel.Where, sb)
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
q := "INSERT INTO `" + ins.Table + "`(" + a.buildColumns(ins.Columns) + ") SELECT" + a.buildJoinColumns(sel.Columns) + " FROM `" + sel.Table + "`" + sb.String() + a.buildOrderby(sel.Orderby) + a.buildLimit(sel.Limit)
|
||||
|
@ -1104,9 +1190,9 @@ func (a *MysqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelec
|
|||
}
|
||||
|
||||
func (a *MysqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error) {
|
||||
whereStr, err := a.buildJoinWhere(sel.Where)
|
||||
if err != nil {
|
||||
return "", err
|
||||
whereStr, e := a.buildJoinWhere(sel.Where)
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
|
||||
q := "INSERT INTO `" + ins.Table + "`(" + a.buildColumns(ins.Columns) + ") SELECT" + a.buildJoinColumns(sel.Columns) + " FROM `" + sel.Table1 + "` LEFT JOIN `" + sel.Table2 + "` ON " + a.buildJoiners(sel.Joiners) + whereStr + a.buildOrderby(sel.Orderby) + a.buildLimit(sel.Limit)
|
||||
|
@ -1117,38 +1203,65 @@ func (a *MysqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoi
|
|||
|
||||
// TODO: Make this more consistent with the other build* methods?
|
||||
func (a *MysqlAdapter) buildJoiners(joiners string) (q string) {
|
||||
for _, j := range processJoiner(joiners) {
|
||||
q += "`" + j.LeftTable + "`.`" + j.LeftColumn + "` " + j.Operator + " `" + j.RightTable + "`.`" + j.RightColumn + "` AND "
|
||||
var qb strings.Builder
|
||||
for i, j := range processJoiner(joiners) {
|
||||
//q += "`" + j.LeftTable + "`.`" + j.LeftColumn + "` " + j.Operator + " `" + j.RightTable + "`.`" + j.RightColumn + "` AND "
|
||||
if i != 0 {
|
||||
qb.WriteString("AND`")
|
||||
} else {
|
||||
qb.WriteString("`")
|
||||
}
|
||||
// Remove the trailing AND
|
||||
return q[0 : len(q)-4]
|
||||
qb.WriteString(j.LeftTable)
|
||||
qb.WriteString("`.`")
|
||||
qb.WriteString(j.LeftColumn)
|
||||
qb.WriteString("` ")
|
||||
qb.WriteString(j.Operator)
|
||||
qb.WriteString(" `")
|
||||
qb.WriteString(j.RightTable)
|
||||
qb.WriteString("`.`")
|
||||
qb.WriteString(j.RightColumn)
|
||||
qb.WriteString("`")
|
||||
}
|
||||
return qb.String()
|
||||
}
|
||||
|
||||
// Add support for BETWEEN x.x
|
||||
func (a *MysqlAdapter) buildJoinWhere(where string) (q string, err error) {
|
||||
func (a *MysqlAdapter) buildJoinWhere(where string) (q string, e error) {
|
||||
if len(where) != 0 {
|
||||
q = " WHERE"
|
||||
for _, loc := range processWhere(where) {
|
||||
var qsb strings.Builder
|
||||
ws := processWhere(where)
|
||||
qsb.Grow(6 + (len(ws) * 5))
|
||||
qsb.WriteString(" WHERE")
|
||||
for i, loc := range ws {
|
||||
if i != 0 {
|
||||
qsb.WriteString(" AND")
|
||||
}
|
||||
for _, token := range loc.Expr {
|
||||
switch token.Type {
|
||||
case TokenFunc, TokenOp, TokenNumber, TokenSub, TokenOr, TokenNot, TokenLike:
|
||||
q += " " + token.Contents
|
||||
qsb.WriteRune(' ')
|
||||
qsb.WriteString(token.Contents)
|
||||
case TokenColumn:
|
||||
qsb.WriteString(" `")
|
||||
halves := strings.Split(token.Contents, ".")
|
||||
if len(halves) == 2 {
|
||||
q += " `" + halves[0] + "`.`" + halves[1] + "`"
|
||||
qsb.WriteString(halves[0])
|
||||
qsb.WriteString("`.`")
|
||||
qsb.WriteString(halves[1])
|
||||
} else {
|
||||
q += " `" + token.Contents + "`"
|
||||
qsb.WriteString(token.Contents)
|
||||
}
|
||||
qsb.WriteRune('`')
|
||||
case TokenString:
|
||||
q += " '" + token.Contents + "'"
|
||||
qsb.WriteString(" '")
|
||||
qsb.WriteString(token.Contents)
|
||||
qsb.WriteRune('\'')
|
||||
default:
|
||||
return q, errors.New("This token doesn't exist o_o")
|
||||
return qsb.String(), errors.New("This token doesn't exist o_o")
|
||||
}
|
||||
}
|
||||
q += " AND"
|
||||
}
|
||||
q = q[0 : len(q)-4]
|
||||
return qsb.String(), nil
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
@ -1175,8 +1288,8 @@ func (a *MysqlAdapter) buildJoinColumns(cols string) (q string) {
|
|||
if firstChar == '\'' {
|
||||
col.Type = TokenString
|
||||
} else {
|
||||
_, err := strconv.Atoi(string(firstChar))
|
||||
if err == nil {
|
||||
_, e := strconv.Atoi(string(firstChar))
|
||||
if e == nil {
|
||||
col.Type = TokenNumber
|
||||
}
|
||||
}
|
||||
|
@ -1185,7 +1298,7 @@ func (a *MysqlAdapter) buildJoinColumns(cols string) (q string) {
|
|||
source := col.Left
|
||||
if col.Table != "" {
|
||||
source = "`" + col.Table + "`.`" + source + "`"
|
||||
} else if col.Type != TokenFunc && col.Type != TokenNumber && col.Type != TokenSub && col.Type != TokenString {
|
||||
} else if col.Type != TokenScope && col.Type != TokenFunc && col.Type != TokenNumber && col.Type != TokenSub && col.Type != TokenString {
|
||||
source = "`" + source + "`"
|
||||
}
|
||||
|
||||
|
@ -1210,9 +1323,9 @@ func (a *MysqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJo
|
|||
return q, nil
|
||||
}
|
||||
|
||||
const sclen1 = len("SELECT COUNT(*) FROM ``")
|
||||
const sclen1 = len("SELECT COUNT(*) FROM``")
|
||||
|
||||
func (a *MysqlAdapter) SimpleCount(name, table, where, limit string) (q string, err error) {
|
||||
func (a *MysqlAdapter) SimpleCount(name, table, where, limit string) (q string, e error) {
|
||||
if table == "" {
|
||||
return "", errors.New("You need a name for this table")
|
||||
}
|
||||
|
@ -1225,12 +1338,11 @@ func (a *MysqlAdapter) SimpleCount(name, table, where, limit string) (q string,
|
|||
sb.Reset()
|
||||
}
|
||||
sb.Grow(sclen1 + len(table))
|
||||
sb.WriteString("SELECT COUNT(*) FROM `")
|
||||
sb.WriteString("SELECT COUNT(*) FROM`")
|
||||
sb.WriteString(table)
|
||||
sb.WriteRune('`')
|
||||
err = a.buildWhere(where, sb)
|
||||
if err != nil {
|
||||
return "", err
|
||||
if e = a.buildWhere(where, sb); e != nil {
|
||||
return "", e
|
||||
}
|
||||
a.buildLimitSb(sb, limit)
|
||||
|
||||
|
@ -1255,21 +1367,21 @@ func (a *MysqlAdapter) Write() error {
|
|||
if stmt.Type == "upsert" {
|
||||
stmts += "\t" + name + " *qgen.MySQLUpsertCallback\n"
|
||||
body += `
|
||||
common.DebugLog("Preparing ` + name + ` statement.")
|
||||
stmts.` + name + `, err = qgen.PrepareMySQLUpsertCallback(db,"` + stmt.Contents + `")
|
||||
if err != nil {
|
||||
log.Print("Error in ` + name + ` statement.")
|
||||
return err
|
||||
dl("Preparing ` + name + ` statement.")
|
||||
stmts.` + name + `, e = qgen.PrepareMySQLUpsertCallback(db,"` + stmt.Contents + `")
|
||||
if e != nil {
|
||||
l("Error in ` + name + ` statement.")
|
||||
return e
|
||||
}
|
||||
`
|
||||
} else if stmt.Type != "create-table" {
|
||||
stmts += "\t" + name + " *sql.Stmt\n"
|
||||
body += `
|
||||
common.DebugLog("Preparing ` + name + ` statement.")
|
||||
stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `")
|
||||
if err != nil {
|
||||
log.Print("Error in ` + name + ` statement.")
|
||||
return err
|
||||
dl("Preparing ` + name + ` statement.")
|
||||
stmts.` + name + `, e = db.Prepare("` + stmt.Contents + `")
|
||||
if e != nil {
|
||||
l("Error in ` + name + ` statement.")
|
||||
return e
|
||||
}
|
||||
`
|
||||
}
|
||||
|
@ -1282,10 +1394,12 @@ func (a *MysqlAdapter) Write() error {
|
|||
|
||||
package main
|
||||
|
||||
import "log"
|
||||
import "database/sql"
|
||||
import "github.com/Azareal/Gosora/common"
|
||||
//import "github.com/Azareal/Gosora/query_gen"
|
||||
import(
|
||||
"log"
|
||||
"database/sql"
|
||||
c "github.com/Azareal/Gosora/common"
|
||||
//"github.com/Azareal/Gosora/query_gen"
|
||||
)
|
||||
|
||||
// nolint
|
||||
type Stmts struct {
|
||||
|
@ -1298,8 +1412,11 @@ type Stmts struct {
|
|||
}
|
||||
|
||||
// nolint
|
||||
func _gen_mysql() (err error) {
|
||||
common.DebugLog("Building the generated statements")
|
||||
func _gen_mysql() (e error) {
|
||||
dl := c.DebugLog
|
||||
dl("Building the generated statements")
|
||||
l := log.Print
|
||||
_ = l
|
||||
` + body + `
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ const (
|
|||
TokenOr
|
||||
TokenNot
|
||||
TokenLike
|
||||
TokenScope
|
||||
)
|
||||
|
||||
type DBToken struct {
|
||||
|
|
|
@ -10,6 +10,7 @@ package qgen
|
|||
import (
|
||||
"os"
|
||||
"strings"
|
||||
//"fmt"
|
||||
)
|
||||
|
||||
// TODO: Add support for numbers and strings?
|
||||
|
@ -34,11 +35,17 @@ func processColumns(colStr string) (columns []DBColumn) {
|
|||
if len(halves) == 2 {
|
||||
outCol.Alias = strings.TrimSpace(halves[1])
|
||||
}
|
||||
if halves[0][len(halves[0])-1] == ')' {
|
||||
//fmt.Printf("halves: %+v\n", halves)
|
||||
//fmt.Printf("halves[0]: %+v\n", halves[0])
|
||||
switch {
|
||||
case halves[0][0] == '(':
|
||||
outCol.Type = TokenScope
|
||||
outCol.Table = ""
|
||||
case halves[0][len(halves[0])-1] == ')':
|
||||
outCol.Type = TokenFunc
|
||||
} else if halves[0] == "?" {
|
||||
case halves[0] == "?":
|
||||
outCol.Type = TokenSub
|
||||
} else {
|
||||
default:
|
||||
outCol.Type = TokenColumn
|
||||
}
|
||||
|
||||
|
@ -144,7 +151,7 @@ func (wh *DBWhere) parseColumn(seg string, i int) int {
|
|||
return i
|
||||
}
|
||||
|
||||
func (wh *DBWhere) parseFunction(seg string, buffer string, i int) int {
|
||||
func (wh *DBWhere) parseFunction(seg, buffer string, i int) int {
|
||||
preI := i
|
||||
i = skipFunctionCall(seg, i-1)
|
||||
buffer += seg[preI:i] + string(seg[i])
|
||||
|
@ -299,7 +306,7 @@ func (set *DBSetter) parseColumn(seg string, i int) int {
|
|||
return i
|
||||
}
|
||||
|
||||
func (set *DBSetter) parseFunction(segment string, buffer string, i int) int {
|
||||
func (set *DBSetter) parseFunction(segment, buffer string, i int) int {
|
||||
preI := i
|
||||
i = skipFunctionCall(segment, i-1)
|
||||
buffer += segment[preI:i] + string(segment[i])
|
||||
|
|
|
@ -265,9 +265,9 @@ func startDirSizeTask() {
|
|||
dstMuGuess = 0
|
||||
dstMu.Unlock()
|
||||
}()
|
||||
dDirSize, err := c.DirSize(".")
|
||||
if err != nil {
|
||||
c.LogWarning(err)
|
||||
dDirSize, e := c.DirSize(".")
|
||||
if e != nil {
|
||||
c.LogWarning(e)
|
||||
}
|
||||
cachedDirSize.Store(dirSize{dDirSize, time.Now()})
|
||||
}()
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func Plugins(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
|
||||
basePage, ferr := buildBasePage(w, r, u, "plugins", "plugins")
|
||||
bp, ferr := buildBasePage(w, r, u, "plugins", "plugins")
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ func Plugins(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError {
|
|||
return c.NoPermissions(w, r, u)
|
||||
}
|
||||
|
||||
var plList []interface{}
|
||||
plList, i := make([]interface{}, len(c.Plugins)), 0
|
||||
for _, pl := range c.Plugins {
|
||||
plList = append(plList, pl)
|
||||
plList[i] = pl
|
||||
i++
|
||||
}
|
||||
|
||||
return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_plugins", c.PanelPage{basePage, plList, nil}})
|
||||
return renderTemplate("panel", w, r, bp.Header, c.Panel{bp, "", "", "panel_plugins", c.PanelPage{bp, plList, nil}})
|
||||
}
|
||||
|
||||
// TODO: Abstract more of the plugin activation / installation / deactivation logic, so we can test all that more reliably and easily
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE [forums_actions] (
|
||||
[faid] int not null IDENTITY,
|
||||
[fid] int not null,
|
||||
[runOnTopicCreation] bit DEFAULT 0 not null,
|
||||
[runDaysAfterTopicCreation] int DEFAULT 0 not null,
|
||||
[runDaysAfterTopicLastReply] int DEFAULT 0 not null,
|
||||
[action] nvarchar (50) not null,
|
||||
[extra] nvarchar (200) DEFAULT '' not null,
|
||||
primary key([faid])
|
||||
);
|
|
@ -6,45 +6,45 @@ ALTER TABLE `emails` ADD INDEX `i_uid` (`uid`);;
|
|||
ALTER TABLE `attachments` ADD INDEX `i_originID` (`originID`);;
|
||||
ALTER TABLE `attachments` ADD INDEX `i_path` (`path`);;
|
||||
ALTER TABLE `activity_stream_matches` ADD INDEX `i_watcher` (`watcher`);;
|
||||
INSERT INTO `sync`(`last_update`) VALUES (UTC_TIMESTAMP());
|
||||
INSERT INTO `settings`(`name`,`content`,`type`,`constraints`) VALUES ('activation_type','1','list','1-3');
|
||||
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('bigpost_min_words','250','int');
|
||||
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('megapost_min_words','1000','int');
|
||||
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('meta_desc','','html-attribute');
|
||||
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('rapid_loading','1','bool');
|
||||
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('google_site_verify','','html-attribute');
|
||||
INSERT INTO `settings`(`name`,`content`,`type`,`constraints`) VALUES ('avatar_visibility','0','list','0-1');
|
||||
INSERT INTO `themes`(`uname`,`default`) VALUES ('cosora',1);
|
||||
INSERT INTO `emails`(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
|
||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
||||
INSERT INTO `forums`(`name`,`active`,`desc`,`tmpl`) VALUES ('Reports',0,'All the reports go here','');
|
||||
INSERT INTO `forums`(`name`,`lastTopicID`,`lastReplyerID`,`desc`,`tmpl`) VALUES ('General',1,1,'A place for general discussions which don''t fit elsewhere','');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (1,1,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"PinTopic":true,"CloseTopic":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (2,1,'{"ViewTopic":true,"CreateReply":true,"CloseTopic":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (3,1,'{}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (4,1,'{}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (5,1,'{}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (6,1,'{}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (1,2,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true,"EditTopic":true,"DeleteTopic":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (2,2,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true,"EditTopic":true,"DeleteTopic":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (3,2,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (4,2,'{"ViewTopic":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (5,2,'{"ViewTopic":true}');
|
||||
INSERT INTO `forums_permissions`(`gid`,`fid`,`permissions`) VALUES (6,2,'{"ViewTopic":true}');
|
||||
INSERT INTO `topics`(`title`,`content`,`parsed_content`,`createdAt`,`lastReplyAt`,`lastReplyBy`,`createdBy`,`parentID`,`ip`) VALUES ('Test Topic','A topic automatically generated by the software.','A topic automatically generated by the software.',UTC_TIMESTAMP(),UTC_TIMESTAMP(),1,1,2,'');
|
||||
INSERT INTO `replies`(`tid`,`content`,`parsed_content`,`createdAt`,`createdBy`,`lastUpdated`,`lastEdit`,`lastEditBy`,`ip`) VALUES (1,'A reply!','A reply!',UTC_TIMESTAMP(),1,UTC_TIMESTAMP(),0,0,'');
|
||||
INSERT INTO `menus`() VALUES ();
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`htmlID`,`position`,`path`,`aria`,`tooltip`,`order`) VALUES (1,'{lang.menu_forums}','menu_forums','left','/forums/','{lang.menu_forums_aria}','{lang.menu_forums_tooltip}',0);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`htmlID`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`order`) VALUES (1,'{lang.menu_topics}','menu_topics','menu_topics','left','/topics/','{lang.menu_topics_aria}','{lang.menu_topics_tooltip}',1);
|
||||
INSERT INTO `menu_items`(`mid`,`htmlID`,`cssClass`,`position`,`tmplName`,`order`) VALUES (1,'general_alerts','menu_alerts','right','menu_alerts',2);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`order`) VALUES (1,'{lang.menu_account}','menu_account','left','/user/edit/','{lang.menu_account_aria}','{lang.menu_account_tooltip}',1,3);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`order`) VALUES (1,'{lang.menu_profile}','menu_profile','left','{me.Link}','{lang.menu_profile_aria}','{lang.menu_profile_tooltip}',1,4);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`staffOnly`,`order`) VALUES (1,'{lang.menu_panel}','menu_panel menu_account','left','/panel/','{lang.menu_panel_aria}','{lang.menu_panel_tooltip}',1,1,5);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`order`) VALUES (1,'{lang.menu_logout}','menu_logout','left','/accounts/logout/?s={me.Session}','{lang.menu_logout_aria}','{lang.menu_logout_tooltip}',1,6);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`guestOnly`,`order`) VALUES (1,'{lang.menu_register}','menu_register','left','/accounts/create/','{lang.menu_register_aria}','{lang.menu_register_tooltip}',1,7);
|
||||
INSERT INTO `menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`guestOnly`,`order`) VALUES (1,'{lang.menu_login}','menu_login','left','/accounts/login/','{lang.menu_login_aria}','{lang.menu_login_tooltip}',1,8);
|
||||
INSERT INTO`sync`(`last_update`)VALUES(UTC_TIMESTAMP());
|
||||
INSERT INTO`settings`(`name`,`content`,`type`,`constraints`)VALUES('activation_type','1','list','1-3');
|
||||
INSERT INTO`settings`(`name`,`content`,`type`)VALUES('bigpost_min_words','250','int');
|
||||
INSERT INTO`settings`(`name`,`content`,`type`)VALUES('megapost_min_words','1000','int');
|
||||
INSERT INTO`settings`(`name`,`content`,`type`)VALUES('meta_desc','','html-attribute');
|
||||
INSERT INTO`settings`(`name`,`content`,`type`)VALUES('rapid_loading','1','bool');
|
||||
INSERT INTO`settings`(`name`,`content`,`type`)VALUES('google_site_verify','','html-attribute');
|
||||
INSERT INTO`settings`(`name`,`content`,`type`,`constraints`)VALUES('avatar_visibility','0','list','0-1');
|
||||
INSERT INTO`themes`(`uname`,`default`)VALUES('cosora',1);
|
||||
INSERT INTO`emails`(`email`,`uid`,`validated`)VALUES('admin@localhost',1,1);
|
||||
INSERT INTO`users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`)VALUES('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
||||
INSERT INTO`users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`)VALUES('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
||||
INSERT INTO`users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`)VALUES('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
||||
INSERT INTO`users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`)VALUES('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
||||
INSERT INTO`users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`)VALUES('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
||||
INSERT INTO`users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`)VALUES('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
||||
INSERT INTO`forums`(`name`,`active`,`desc`,`tmpl`)VALUES('Reports',0,'All the reports go here','');
|
||||
INSERT INTO`forums`(`name`,`lastTopicID`,`lastReplyerID`,`desc`,`tmpl`)VALUES('General',1,1,'A place for general discussions which don''t fit elsewhere','');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(1,1,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"PinTopic":true,"CloseTopic":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(2,1,'{"ViewTopic":true,"CreateReply":true,"CloseTopic":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(3,1,'{}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(4,1,'{}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(5,1,'{}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(6,1,'{}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(1,2,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true,"EditTopic":true,"DeleteTopic":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(2,2,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true,"EditTopic":true,"DeleteTopic":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(3,2,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"LikeItem":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(4,2,'{"ViewTopic":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(5,2,'{"ViewTopic":true}');
|
||||
INSERT INTO`forums_permissions`(`gid`,`fid`,`permissions`)VALUES(6,2,'{"ViewTopic":true}');
|
||||
INSERT INTO`topics`(`title`,`content`,`parsed_content`,`createdAt`,`lastReplyAt`,`lastReplyBy`,`createdBy`,`parentID`,`ip`)VALUES('Test Topic','A topic automatically generated by the software.','A topic automatically generated by the software.',UTC_TIMESTAMP(),UTC_TIMESTAMP(),1,1,2,'');
|
||||
INSERT INTO`replies`(`tid`,`content`,`parsed_content`,`createdAt`,`createdBy`,`lastUpdated`,`lastEdit`,`lastEditBy`,`ip`)VALUES(1,'A reply!','A reply!',UTC_TIMESTAMP(),1,UTC_TIMESTAMP(),0,0,'');
|
||||
INSERT INTO`menus`()VALUES();
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`htmlID`,`position`,`path`,`aria`,`tooltip`,`order`)VALUES(1,'{lang.menu_forums}','menu_forums','left','/forums/','{lang.menu_forums_aria}','{lang.menu_forums_tooltip}',0);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`htmlID`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`order`)VALUES(1,'{lang.menu_topics}','menu_topics','menu_topics','left','/topics/','{lang.menu_topics_aria}','{lang.menu_topics_tooltip}',1);
|
||||
INSERT INTO`menu_items`(`mid`,`htmlID`,`cssClass`,`position`,`tmplName`,`order`)VALUES(1,'general_alerts','menu_alerts','right','menu_alerts',2);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`order`)VALUES(1,'{lang.menu_account}','menu_account','left','/user/edit/','{lang.menu_account_aria}','{lang.menu_account_tooltip}',1,3);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`order`)VALUES(1,'{lang.menu_profile}','menu_profile','left','{me.Link}','{lang.menu_profile_aria}','{lang.menu_profile_tooltip}',1,4);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`staffOnly`,`order`)VALUES(1,'{lang.menu_panel}','menu_panel menu_account','left','/panel/','{lang.menu_panel_aria}','{lang.menu_panel_tooltip}',1,1,5);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`memberOnly`,`order`)VALUES(1,'{lang.menu_logout}','menu_logout','left','/accounts/logout/?s={me.Session}','{lang.menu_logout_aria}','{lang.menu_logout_tooltip}',1,6);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`guestOnly`,`order`)VALUES(1,'{lang.menu_register}','menu_register','left','/accounts/create/','{lang.menu_register_aria}','{lang.menu_register_tooltip}',1,7);
|
||||
INSERT INTO`menu_items`(`mid`,`name`,`cssClass`,`position`,`path`,`aria`,`tooltip`,`guestOnly`,`order`)VALUES(1,'{lang.menu_login}','menu_login','left','/accounts/login/','{lang.menu_login_aria}','{lang.menu_login_tooltip}',1,8);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `activity_stream` (
|
||||
CREATE TABLE `activity_stream`(
|
||||
`asid` int not null AUTO_INCREMENT,
|
||||
`actor` int not null,
|
||||
`targetUser` int not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `activity_stream_matches` (
|
||||
CREATE TABLE `activity_stream_matches`(
|
||||
`watcher` int not null,
|
||||
`asid` int not null,
|
||||
foreign key(`asid`) REFERENCES `activity_stream`(`asid`) ON DELETE CASCADE
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `activity_subscriptions` (
|
||||
CREATE TABLE `activity_subscriptions`(
|
||||
`user` int not null,
|
||||
`targetID` int not null,
|
||||
`targetType` varchar(50) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `administration_logs` (
|
||||
CREATE TABLE `administration_logs`(
|
||||
`action` varchar(100) not null,
|
||||
`elementID` int not null,
|
||||
`elementType` varchar(100) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `attachments` (
|
||||
CREATE TABLE `attachments`(
|
||||
`attachID` int not null AUTO_INCREMENT,
|
||||
`sectionID` int DEFAULT 0 not null,
|
||||
`sectionTable` varchar(200) DEFAULT 'forums' not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `conversations` (
|
||||
CREATE TABLE `conversations`(
|
||||
`cid` int not null AUTO_INCREMENT,
|
||||
`createdBy` int not null,
|
||||
`createdAt` datetime not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `conversations_participants` (
|
||||
CREATE TABLE `conversations_participants`(
|
||||
`uid` int not null,
|
||||
`cid` int not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `conversations_posts` (
|
||||
CREATE TABLE `conversations_posts`(
|
||||
`pid` int not null AUTO_INCREMENT,
|
||||
`cid` int not null,
|
||||
`createdBy` int not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `emails` (
|
||||
CREATE TABLE `emails`(
|
||||
`email` varchar(200) not null,
|
||||
`uid` int not null,
|
||||
`validated` boolean DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `forums` (
|
||||
CREATE TABLE `forums`(
|
||||
`fid` int not null AUTO_INCREMENT,
|
||||
`name` varchar(100) not null,
|
||||
`desc` varchar(200) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `forums_actions` (
|
||||
CREATE TABLE `forums_actions`(
|
||||
`faid` int not null AUTO_INCREMENT,
|
||||
`fid` int not null,
|
||||
`runOnTopicCreation` boolean DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `forums_permissions` (
|
||||
CREATE TABLE `forums_permissions`(
|
||||
`fid` int not null,
|
||||
`gid` int not null,
|
||||
`preset` varchar(100) DEFAULT '' not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `likes` (
|
||||
CREATE TABLE `likes`(
|
||||
`weight` tinyint DEFAULT 1 not null,
|
||||
`targetItem` int not null,
|
||||
`targetType` varchar(50) DEFAULT 'replies' not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `login_logs` (
|
||||
CREATE TABLE `login_logs`(
|
||||
`lid` int not null AUTO_INCREMENT,
|
||||
`uid` int not null,
|
||||
`success` boolean DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `memchunks` (
|
||||
CREATE TABLE `memchunks`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`stack` int DEFAULT 0 not null,
|
||||
`heap` int DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `menu_items` (
|
||||
CREATE TABLE `menu_items`(
|
||||
`miid` int not null AUTO_INCREMENT,
|
||||
`mid` int not null,
|
||||
`name` varchar(200) DEFAULT '' not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `menus` (
|
||||
CREATE TABLE `menus`(
|
||||
`mid` int not null AUTO_INCREMENT,
|
||||
primary key(`mid`)
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `meta` (
|
||||
CREATE TABLE `meta`(
|
||||
`name` varchar(200) not null,
|
||||
`value` varchar(200) not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `moderation_logs` (
|
||||
CREATE TABLE `moderation_logs`(
|
||||
`action` varchar(100) not null,
|
||||
`elementID` int not null,
|
||||
`elementType` varchar(100) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `pages` (
|
||||
CREATE TABLE `pages`(
|
||||
`pid` int not null AUTO_INCREMENT,
|
||||
`name` varchar(200) not null,
|
||||
`title` varchar(200) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `password_resets` (
|
||||
CREATE TABLE `password_resets`(
|
||||
`email` varchar(200) not null,
|
||||
`uid` int not null,
|
||||
`validated` varchar(200) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `perfchunks` (
|
||||
CREATE TABLE `perfchunks`(
|
||||
`low` int DEFAULT 0 not null,
|
||||
`high` int DEFAULT 0 not null,
|
||||
`avg` int DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `plugins` (
|
||||
CREATE TABLE `plugins`(
|
||||
`uname` varchar(180) not null,
|
||||
`active` boolean DEFAULT 0 not null,
|
||||
`installed` boolean DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `polls` (
|
||||
CREATE TABLE `polls`(
|
||||
`pollID` int not null AUTO_INCREMENT,
|
||||
`parentID` int DEFAULT 0 not null,
|
||||
`parentTable` varchar(100) DEFAULT 'topics' not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `polls_options` (
|
||||
CREATE TABLE `polls_options`(
|
||||
`pollID` int not null,
|
||||
`option` int DEFAULT 0 not null,
|
||||
`votes` int DEFAULT 0 not null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `polls_votes` (
|
||||
CREATE TABLE `polls_votes`(
|
||||
`pollID` int not null,
|
||||
`uid` int not null,
|
||||
`option` int DEFAULT 0 not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `postchunks` (
|
||||
CREATE TABLE `postchunks`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `registration_logs` (
|
||||
CREATE TABLE `registration_logs`(
|
||||
`rlid` int not null AUTO_INCREMENT,
|
||||
`username` varchar(100) not null,
|
||||
`email` varchar(100) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `replies` (
|
||||
CREATE TABLE `replies`(
|
||||
`rid` int not null AUTO_INCREMENT,
|
||||
`tid` int not null,
|
||||
`content` text not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `revisions` (
|
||||
CREATE TABLE `revisions`(
|
||||
`reviseID` int not null AUTO_INCREMENT,
|
||||
`content` text not null,
|
||||
`contentID` int not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `settings` (
|
||||
CREATE TABLE `settings`(
|
||||
`name` varchar(180) not null,
|
||||
`content` varchar(250) not null,
|
||||
`type` varchar(50) not null,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
CREATE TABLE `sync` (
|
||||
CREATE TABLE `sync`(
|
||||
`last_update` datetime not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `themes` (
|
||||
CREATE TABLE `themes`(
|
||||
`uname` varchar(180) not null,
|
||||
`default` boolean DEFAULT 0 not null,
|
||||
unique(`uname`)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `topicchunks` (
|
||||
CREATE TABLE `topicchunks`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `topics` (
|
||||
CREATE TABLE `topics`(
|
||||
`tid` int not null AUTO_INCREMENT,
|
||||
`title` varchar(100) not null,
|
||||
`content` text not null,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
CREATE TABLE `updates` (
|
||||
CREATE TABLE `updates`(
|
||||
`dbVersion` int DEFAULT 0 not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users` (
|
||||
CREATE TABLE `users`(
|
||||
`uid` int not null AUTO_INCREMENT,
|
||||
`name` varchar(100) not null,
|
||||
`password` varchar(100) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_2fa_keys` (
|
||||
CREATE TABLE `users_2fa_keys`(
|
||||
`uid` int not null,
|
||||
`secret` varchar(100) not null,
|
||||
`scratch1` varchar(50) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_avatar_queue` (
|
||||
CREATE TABLE `users_avatar_queue`(
|
||||
`uid` int not null,
|
||||
primary key(`uid`)
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_blocks` (
|
||||
CREATE TABLE `users_blocks`(
|
||||
`blocker` int not null,
|
||||
`blockedUser` int not null
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_groups` (
|
||||
CREATE TABLE `users_groups`(
|
||||
`gid` int not null AUTO_INCREMENT,
|
||||
`name` varchar(100) not null,
|
||||
`permissions` text not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_groups_promotions` (
|
||||
CREATE TABLE `users_groups_promotions`(
|
||||
`pid` int not null AUTO_INCREMENT,
|
||||
`from_gid` int not null,
|
||||
`to_gid` int not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_groups_scheduler` (
|
||||
CREATE TABLE `users_groups_scheduler`(
|
||||
`uid` int not null,
|
||||
`set_group` int not null,
|
||||
`issued_by` int not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `users_replies` (
|
||||
CREATE TABLE `users_replies`(
|
||||
`rid` int not null AUTO_INCREMENT,
|
||||
`uid` int not null,
|
||||
`content` text not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `viewchunks` (
|
||||
CREATE TABLE `viewchunks`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`avg` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `viewchunks_agents` (
|
||||
CREATE TABLE `viewchunks_agents`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null,
|
||||
`browser` varchar(200) not null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `viewchunks_forums` (
|
||||
CREATE TABLE `viewchunks_forums`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null,
|
||||
`forum` int not null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `viewchunks_langs` (
|
||||
CREATE TABLE `viewchunks_langs`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null,
|
||||
`lang` varchar(200) not null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `viewchunks_referrers` (
|
||||
CREATE TABLE `viewchunks_referrers`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null,
|
||||
`domain` varchar(200) not null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `viewchunks_systems` (
|
||||
CREATE TABLE `viewchunks_systems`(
|
||||
`count` int DEFAULT 0 not null,
|
||||
`createdAt` datetime not null,
|
||||
`system` varchar(200) not null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `widgets` (
|
||||
CREATE TABLE `widgets`(
|
||||
`wid` int not null AUTO_INCREMENT,
|
||||
`position` int not null,
|
||||
`side` varchar(100) not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE `word_filters` (
|
||||
CREATE TABLE `word_filters`(
|
||||
`wfid` int not null AUTO_INCREMENT,
|
||||
`find` varchar(200) not null,
|
||||
`replacement` varchar(200) not null,
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE "forums_actions" (
|
||||
`faid` serial not null,
|
||||
`fid` int not null,
|
||||
`runOnTopicCreation` boolean DEFAULT 0 not null,
|
||||
`runDaysAfterTopicCreation` int DEFAULT 0 not null,
|
||||
`runDaysAfterTopicLastReply` int DEFAULT 0 not null,
|
||||
`action` varchar (50) not null,
|
||||
`extra` varchar (200) DEFAULT '' not null,
|
||||
primary key(`faid`)
|
||||
);
|
Loading…
Reference in New Issue