mirror of
https://github.com/documize/community.git
synced 2025-08-05 05:25:27 +02:00
Continued MySQL/PostgreSQL store provider refactoring
Refactored, renamed, removed storage related code. Basic smoke test passed for PostgreSQL whilst fully working on MySQL variants as per usual.
This commit is contained in:
parent
b455e5eaf5
commit
97beb3f4d3
81 changed files with 1454 additions and 1497 deletions
|
@ -28,7 +28,7 @@ import (
|
|||
// Store provides data access to organization (tenant) information.
|
||||
type Store struct {
|
||||
store.Context
|
||||
domain.OrganizationStorer
|
||||
store.OrganizationStorer
|
||||
}
|
||||
|
||||
// AddOrganization inserts the passed organization record into the organization table.
|
||||
|
@ -94,12 +94,11 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_authconfig,`+s.EmptyJSON()+`) AS authconfig, c_maxtags AS maxtags,
|
||||
c_created AS created, c_revised AS revised
|
||||
FROM dmz_org
|
||||
WHERE c_domain=? AND c_active=1`),
|
||||
WHERE c_domain=? AND c_active=true`),
|
||||
subdomain)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(err)
|
||||
err = nil
|
||||
|
||||
// match on empty domain AS last resort
|
||||
|
@ -110,7 +109,7 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_authconfig,`+s.EmptyJSON()+`) AS authconfig, c_maxtags AS maxtags,
|
||||
c_created AS created, c_revised AS revised
|
||||
FROM dmz_org
|
||||
WHERE c_domain='' AND c_active=1`))
|
||||
WHERE c_domain='' AND c_active=true`))
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "unable to execute select for empty subdomain")
|
||||
|
@ -143,7 +142,7 @@ func (s Store) DeleteOrganization(ctx domain.RequestContext, orgID string) (rows
|
|||
|
||||
// RemoveOrganization sets the orgID organization to be inactive, thus executing a "soft delete" operation.
|
||||
func (s Store) RemoveOrganization(ctx domain.RequestContext, orgID string) (err error) {
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active=0 WHERE c_refid=?"), orgID)
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active=false WHERE c_refid=?"), orgID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute soft delete for org %s", orgID))
|
||||
|
@ -171,7 +170,7 @@ func (s Store) UpdateAuthConfig(ctx domain.RequestContext, org org.Organization)
|
|||
|
||||
// CheckDomain makes sure there is an organisation with the correct domain
|
||||
func (s Store) CheckDomain(ctx domain.RequestContext, domain string) string {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active=1"), domain)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active=true"), domain)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue