mirror of
https://github.com/documize/community.git
synced 2025-07-18 20:59:43 +02:00
Fixed up more SQL store breaking changes
This commit is contained in:
parent
5376bd88d8
commit
944fd98421
10 changed files with 15 additions and 15 deletions
|
@ -35,7 +35,7 @@ func (s Scope) Add(ctx domain.RequestContext, a attachment.Attachment) (err erro
|
|||
bits := strings.Split(a.Filename, ".")
|
||||
a.Extension = bits[len(bits)-1]
|
||||
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_doc_attachment (c_refid, c_orgid, c_documentid, c_job, c_fileid, c_filename, c_data, c_extension, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_doc_attachment (c_refid, c_orgid, c_docid, c_job, c_fileid, c_filename, c_data, c_extension, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
a.RefID, a.OrgID, a.DocumentID, a.Job, a.FileID, a.Filename, a.Data, a.Extension, a.Created, a.Revised)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -34,7 +34,7 @@ func (s Scope) Add(ctx domain.RequestContext, b block.Block) (err error) {
|
|||
b.Created = time.Now().UTC()
|
||||
b.Revised = time.Now().UTC()
|
||||
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_section_template (c_refid, c_orgid, c_spaceid, c_userid, c_contenttype, c_type, c_name, c_body, c_desc, c_rawbody, c_config, c_external, used, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_section_template (c_refid, c_orgid, c_spaceid, c_userid, c_contenttype, c_type, c_name, c_body, c_desc, c_rawbody, c_config, c_external, c_used, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
b.RefID, b.OrgID, b.SpaceID, b.UserID, b.ContentType, b.Type, b.Name, b.Body, b.Excerpt, b.RawBody, b.Config, b.ExternalSource, b.Used, b.Created, b.Revised)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -159,7 +159,7 @@ func (s Scope) AssociateDocument(ctx domain.RequestContext, m category.Member) (
|
|||
m.Created = time.Now().UTC()
|
||||
m.Revised = time.Now().UTC()
|
||||
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_category_member (c_refid, c_orgid, c_categoryid, c_spaceid, docid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_category_member (c_refid, c_orgid, c_categoryid, c_spaceid, c_docid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
m.RefID, m.OrgID, m.CategoryID, m.SpaceID, m.DocumentID, m.Created, m.Revised)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s Scope) Add(ctx domain.RequestContext, d doc.Document) (err error) {
|
|||
d.Revised = d.Created // put same time in both fields
|
||||
|
||||
_, err = ctx.Transaction.Exec(`
|
||||
INSERT INTO dmz_doc (c_refid, c_orgid, c_spaceid, c_userid, c_job, c_location, c_name, c_desc as excerpt, c_slug, c_tags, c_template, c_protection, c_approval, c_lifecycle, c_versioned, c_versionid, c_versionorder, c_groupid, c_created, c_revised)
|
||||
INSERT INTO dmz_doc (c_refid, c_orgid, c_spaceid, c_userid, c_job, c_location, c_name, c_desc, c_slug, c_tags, c_template, c_protection, c_approval, c_lifecycle, c_versioned, c_versionid, c_versionorder, c_groupid, c_created, c_revised)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
d.RefID, d.OrgID, d.SpaceID, d.UserID, d.Job, d.Location, d.Name, d.Excerpt, d.Slug, d.Tags,
|
||||
d.Template, d.Protection, d.Approval, d.Lifecycle, d.Versioned, d.VersionID, d.VersionOrder, d.GroupID, d.Created, d.Revised)
|
||||
|
@ -312,7 +312,7 @@ func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64,
|
|||
// Remove document pages, revisions, attachments, updates the search subsystem.
|
||||
func (s Scope) DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows int64, err error) {
|
||||
b := mysql.BaseQuery{}
|
||||
rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_section WHERE _cdocid IN (SELECT c_refid FROM dmz_doc WHERE c_spaceid=\"%s\" AND c_orgid=\"%s\")", spaceID, ctx.OrgID))
|
||||
rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_section WHERE c_docid IN (SELECT c_refid FROM dmz_doc WHERE c_spaceid=\"%s\" AND c_orgid=\"%s\")", spaceID, ctx.OrgID))
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -333,7 +333,7 @@ func (s Scope) DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows in
|
|||
return
|
||||
}
|
||||
|
||||
return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, spaceID)
|
||||
return b.DeleteConstrained(ctx.Transaction, "dmz_doc", ctx.OrgID, spaceID)
|
||||
}
|
||||
|
||||
// GetVersions returns a slice containing the documents for a given space.
|
||||
|
|
|
@ -159,7 +159,7 @@ func (s Scope) GetMembers(ctx domain.RequestContext) (r []group.Record, err erro
|
|||
SELECT a.id, a.c_orgid AS orgid, a.c_groupid AS groupid, a.c_userid AS userid,
|
||||
b.c_name As name, b.c_desc AS purpose
|
||||
FROM dmz_group_member a, dmz_group b
|
||||
WHERE a.c_orgid=? AND a.c_groupid=b.refid
|
||||
WHERE a.c_orgid=? AND a.c_groupid=b.c_refid
|
||||
ORDER BY a.c_userid`,
|
||||
ctx.OrgID)
|
||||
|
||||
|
|
|
@ -160,10 +160,10 @@ func (s Scope) SearchCandidates(ctx domain.RequestContext, keywords string) (doc
|
|||
// find matching documents
|
||||
temp := []link.Candidate{}
|
||||
keywords = strings.TrimSpace(strings.ToLower(keywords))
|
||||
likeQuery := "LOWER(c_name) LIKE '%" + keywords + "%'"
|
||||
likeQuery := "LOWER(d.c_name) LIKE '%" + keywords + "%'"
|
||||
|
||||
err = s.Runtime.Db.Select(&temp, `
|
||||
SELECT d.c_refid AS documentid, d.c_spaceid AS spaceid, d.c_name, l.c_name AS context
|
||||
SELECT d.c_refid AS documentid, d.c_spaceid AS spaceid, d.c_name AS title, l.c_name AS context
|
||||
FROM dmz_doc d LEFT JOIN dmz_space l ON d.c_spaceid=l.c_refid
|
||||
WHERE l.c_orgid=? AND `+likeQuery+` AND d.c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
|
@ -237,11 +237,11 @@ func (s Scope) SearchCandidates(ctx domain.RequestContext, keywords string) (doc
|
|||
}
|
||||
|
||||
// find matching attachments
|
||||
likeQuery = "LOWER(a.filename) LIKE '%" + keywords + "%'"
|
||||
likeQuery = "LOWER(a.c_filename) LIKE '%" + keywords + "%'"
|
||||
temp = []link.Candidate{}
|
||||
|
||||
err = s.Runtime.Db.Select(&temp, `
|
||||
SELECT a.c_refid AS targetid, a.c_docid AS documentid, a.c_filename AS title, a.c_extension AS context, d.c_spaceiid AS spaceid
|
||||
SELECT a.c_refid AS targetid, a.c_docid AS documentid, a.c_filename AS title, a.c_extension AS context, d.c_spaceid AS spaceid
|
||||
FROM dmz_doc_attachment a LEFT JOIN dmz_doc d ON d.c_refid=a.c_docid
|
||||
WHERE a.c_orgid=? AND `+likeQuery+` AND d.c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
|
|
|
@ -197,7 +197,7 @@ func (s Scope) Update(ctx domain.RequestContext, page page.Page, refID, userID s
|
|||
// It then propagates that change into the search table, adds a delete the page revisions history, and audits that the page has been removed.
|
||||
func (s Scope) Delete(ctx domain.RequestContext, documentID, pageID string) (rows int64, err error) {
|
||||
b := mysql.BaseQuery{}
|
||||
rows, err = b.DeleteConstrained(ctx.Transaction, "page", ctx.OrgID, pageID)
|
||||
rows, err = b.DeleteConstrained(ctx.Transaction, "dmz_section", ctx.OrgID, pageID)
|
||||
|
||||
if err == nil {
|
||||
_, _ = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_section_meta WHERE c_orgid='%s' AND c_sectionid='%s'", ctx.OrgID, pageID))
|
||||
|
|
|
@ -226,7 +226,7 @@ func (s Scope) matchFullText(ctx domain.RequestContext, keywords, itemType strin
|
|||
WHERE
|
||||
s.c_orgid = ?
|
||||
AND s.c_itemtype = ?
|
||||
AND s.c_docid = d.refid
|
||||
AND s.c_docid = d.c_refid
|
||||
AND d.c_spaceid IN
|
||||
(
|
||||
SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
|
||||
|
||||
> .syntax {
|
||||
margin: 20px;
|
||||
margin: 20px 0;
|
||||
|
||||
> .example {
|
||||
margin-top: 10px;
|
||||
|
|
|
@ -30,7 +30,7 @@ var testHost string // used during automated testing
|
|||
|
||||
// Start router to handle all HTTP traffic.
|
||||
func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
|
||||
rt.Log.Info(fmt.Sprintf("Edition: %s version %s", rt.Product.Title, rt.Product.Version))
|
||||
rt.Log.Info(fmt.Sprintf("Product: %s version %s", rt.Product.Title, rt.Product.Version))
|
||||
|
||||
// decide which mode to serve up
|
||||
switch rt.Flags.SiteMode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue