mirror of
https://github.com/documize/community.git
synced 2025-07-24 23:59:47 +02:00
PostgreSQL prep
Update of vendored SQL libs and refactoring of store provider layer.
This commit is contained in:
parent
d0e005f638
commit
b455e5eaf5
105 changed files with 10949 additions and 2376 deletions
2
core/env/flags.go
vendored
2
core/env/flags.go
vendored
|
@ -80,7 +80,7 @@ func ParseFlags() (f Flags) {
|
|||
register(&port, "port", false, "http/https port number")
|
||||
register(&forcePort2SSL, "forcesslport", false, "redirect given http port number to TLS")
|
||||
register(&siteMode, "offline", false, "set to '1' for OFFLINE mode")
|
||||
register(&dbType, "dbtype", true, "specify the database provider: mysql|percona|mariadb|postgressql")
|
||||
register(&dbType, "dbtype", true, "specify the database provider: mysql|percona|mariadb|postgresql")
|
||||
register(&dbConn, "db", true, `'database specific connection string for example "user:password@tcp(localhost:3306)/dbname"`)
|
||||
|
||||
parse("db")
|
||||
|
|
109
core/env/provider.go
vendored
Normal file
109
core/env/provider.go
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
// Package env provides runtime, server level setup and configuration
|
||||
package env
|
||||
|
||||
// StoreType represents name of database system
|
||||
type StoreType string
|
||||
|
||||
const (
|
||||
// StoreTypeMySQL is MySQL
|
||||
StoreTypeMySQL StoreType = "MySQL"
|
||||
|
||||
// StoreTypePercona is Percona
|
||||
StoreTypePercona StoreType = "Percona"
|
||||
|
||||
// StoreTypeMariaDB is MariaDB
|
||||
StoreTypeMariaDB StoreType = "MariaDB"
|
||||
|
||||
// StoreTypePostgreSQL is PostgreSQL
|
||||
StoreTypePostgreSQL StoreType = "PostgreSQL"
|
||||
|
||||
// StoreTypeMSSQL is Microsoft SQL Server
|
||||
StoreTypeMSSQL StoreType = "MSSQL"
|
||||
)
|
||||
|
||||
// StoreProvider defines a database provider.
|
||||
type StoreProvider interface {
|
||||
// Name of provider
|
||||
Type() StoreType
|
||||
|
||||
// TypeVariant returns flavor of database provider.
|
||||
TypeVariant() string
|
||||
|
||||
// SQL driver name used to open DB connection.
|
||||
DriverName() string
|
||||
|
||||
// Database connection string parameters that must be present before connecting to DB.
|
||||
Params() map[string]string
|
||||
|
||||
// Example holds storage provider specific connection string format.
|
||||
// used in error messages
|
||||
Example() string
|
||||
|
||||
// DatabaseName holds the SQL database name where Documize tables live.
|
||||
DatabaseName() string
|
||||
|
||||
// Make connection string with default parameters.
|
||||
MakeConnectionString() string
|
||||
|
||||
// QueryMeta is how to extract version number, collation, character set from database provider.
|
||||
QueryMeta() string
|
||||
|
||||
// QueryStartLock locks database tables.
|
||||
// QueryStartLock() string
|
||||
|
||||
// QueryFinishLock unlocks database tables.
|
||||
// QueryFinishLock() string
|
||||
|
||||
// QueryInsertProcessID returns database specific query that will
|
||||
// insert ID of this running process.
|
||||
// QueryInsertProcessID() string
|
||||
|
||||
// QueryInsertProcessID returns database specific query that will
|
||||
// delete ID of this running process.
|
||||
// QueryDeleteProcessID() string
|
||||
|
||||
// QueryRecordVersionUpgrade returns database specific insert statement
|
||||
// that records the database version number.
|
||||
QueryRecordVersionUpgrade(version int) string
|
||||
|
||||
// QueryRecordVersionUpgrade returns database specific insert statement
|
||||
// that records the database version number.
|
||||
// For use on databases before The Great Schema Migration (v25, MySQL).
|
||||
QueryRecordVersionUpgradeLegacy(version int) string
|
||||
|
||||
// QueryGetDatabaseVersion returns the schema version number.
|
||||
QueryGetDatabaseVersion() string
|
||||
|
||||
// QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL).
|
||||
QueryGetDatabaseVersionLegacy() string
|
||||
|
||||
// QueryTableList returns a list tables in Documize database.
|
||||
QueryTableList() string
|
||||
|
||||
// JSONEmpty returns empty SQL JSON object.
|
||||
// Typically used as 2nd parameter to COALESCE().
|
||||
JSONEmpty() string
|
||||
|
||||
// JSONGetValue returns JSON attribute selection syntax.
|
||||
// Typically used in SELECT <my_json_field> query.
|
||||
JSONGetValue(column, attribute string) string
|
||||
|
||||
// VerfiyVersion checks to see if actual database meets
|
||||
// minimum version requirements.
|
||||
VerfiyVersion(dbVersion string) (versionOK bool, minVerRequired string)
|
||||
|
||||
// VerfiyCharacterCollation checks to see if actual database
|
||||
// has correct character set and collation settings.
|
||||
VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
|
||||
}
|
90
core/env/runtime.go
vendored
90
core/env/runtime.go
vendored
|
@ -16,8 +16,6 @@ import (
|
|||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
// SQL-STORE: DbVariant needs to be struct like: name, delims, std params and conn string method
|
||||
|
||||
// Runtime provides access to database, logger and other server-level scoped objects.
|
||||
// Use Context for per-request values.
|
||||
type Runtime struct {
|
||||
|
@ -42,94 +40,6 @@ const (
|
|||
SiteModeBadDB = "3"
|
||||
)
|
||||
|
||||
// StoreType represents name of database system
|
||||
type StoreType string
|
||||
|
||||
const (
|
||||
// StoreTypeMySQL is MySQL
|
||||
StoreTypeMySQL StoreType = "MySQL"
|
||||
|
||||
// StoreTypePercona is Percona
|
||||
StoreTypePercona StoreType = "Percona"
|
||||
|
||||
// StoreTypeMariaDB is MariaDB
|
||||
StoreTypeMariaDB StoreType = "MariaDB"
|
||||
|
||||
// StoreTypePostgreSQL is PostgreSQL
|
||||
StoreTypePostgreSQL StoreType = "PostgreSQL"
|
||||
|
||||
// StoreTypeMSSQL is Microsoft SQL Server
|
||||
StoreTypeMSSQL StoreType = "MSSQL"
|
||||
)
|
||||
|
||||
// StoreProvider defines a database provider.
|
||||
type StoreProvider interface {
|
||||
// Name of provider
|
||||
Type() StoreType
|
||||
|
||||
// TypeVariant returns flavor of database provider.
|
||||
TypeVariant() string
|
||||
|
||||
// SQL driver name used to open DB connection.
|
||||
DriverName() string
|
||||
|
||||
// Database connection string parameters that must be present before connecting to DB.
|
||||
Params() map[string]string
|
||||
|
||||
// Example holds storage provider specific connection string format.
|
||||
// used in error messages
|
||||
Example() string
|
||||
|
||||
// DatabaseName holds the SQL database name where Documize tables live.
|
||||
DatabaseName() string
|
||||
|
||||
// Make connection string with default parameters.
|
||||
MakeConnectionString() string
|
||||
|
||||
// QueryMeta is how to extract version number, collation, character set from database provider.
|
||||
QueryMeta() string
|
||||
|
||||
// QueryStartLock locks database tables.
|
||||
QueryStartLock() string
|
||||
|
||||
// QueryFinishLock unlocks database tables.
|
||||
QueryFinishLock() string
|
||||
|
||||
// QueryInsertProcessID returns database specific query that will
|
||||
// insert ID of this running process.
|
||||
QueryInsertProcessID() string
|
||||
|
||||
// QueryInsertProcessID returns database specific query that will
|
||||
// delete ID of this running process.
|
||||
QueryDeleteProcessID() string
|
||||
|
||||
// QueryRecordVersionUpgrade returns database specific insert statement
|
||||
// that records the database version number.
|
||||
QueryRecordVersionUpgrade(version int) string
|
||||
|
||||
// QueryRecordVersionUpgrade returns database specific insert statement
|
||||
// that records the database version number.
|
||||
// For use on databases before The Great Schema Migration (v25, MySQL).
|
||||
QueryRecordVersionUpgradeLegacy(version int) string
|
||||
|
||||
// QueryGetDatabaseVersion returns the schema version number.
|
||||
QueryGetDatabaseVersion() string
|
||||
|
||||
// QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL).
|
||||
QueryGetDatabaseVersionLegacy() string
|
||||
|
||||
// QueryTableList returns a list tables in Documize database.
|
||||
QueryTableList() string
|
||||
|
||||
// VerfiyVersion checks to see if actual database meets
|
||||
// minimum version requirements.
|
||||
VerfiyVersion(dbVersion string) (versionOK bool, minVerRequired string)
|
||||
|
||||
// VerfiyCharacterCollation checks to see if actual database
|
||||
// has correct character set and collation settings.
|
||||
VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
|
||||
}
|
||||
|
||||
const (
|
||||
// CommunityEdition is AGPL product variant
|
||||
CommunityEdition = "Community"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue