mirror of
https://github.com/documize/community.git
synced 2025-07-20 13:49:42 +02:00
Add experimental string to timestamp for backup/restore
This commit is contained in:
parent
3913995dd0
commit
1d8bb2d3ad
3 changed files with 25 additions and 14 deletions
21
core/env/provider.go
vendored
21
core/env/provider.go
vendored
|
@ -59,20 +59,6 @@ type StoreProvider interface {
|
|||
// 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
|
||||
|
@ -110,4 +96,11 @@ type StoreProvider interface {
|
|||
// VerfiyCharacterCollation checks to see if actual database
|
||||
// has correct character set and collation settings.
|
||||
VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
|
||||
|
||||
// ConvertTimestamp returns SQL function to correctly convert
|
||||
// ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific
|
||||
// timestamp value (e.g. 2016-09-08 06:37:23).
|
||||
// Must use ? for parameter placeholder character as DB layer
|
||||
// will convert to database specific parameter placeholder character.
|
||||
ConvertTimestamp() (statement string)
|
||||
}
|
||||
|
|
|
@ -339,6 +339,15 @@ func (p MySQLProvider) VerfiyCharacterCollation(charset, collation string) (char
|
|||
return true, ""
|
||||
}
|
||||
|
||||
// ConvertTimestamp returns SQL function to correctly convert
|
||||
// ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific
|
||||
// timestamp value (e.g. 2016-09-08 06:37:23).
|
||||
// Must use ? for parameter placeholder character as DB layer
|
||||
// will convert to database specific parameter placeholder character.
|
||||
func (p MySQLProvider) ConvertTimestamp() (statement string) {
|
||||
return `STR_TO_DATE(?,'%Y-%m-%d %H:%i:%s')`
|
||||
}
|
||||
|
||||
// convertDatabaseVersion turns database version string as major,minor,patch numerics.
|
||||
func convertDatabaseVersion(v string) (ints []int, err error) {
|
||||
ints = []int{0, 0, 0}
|
||||
|
|
|
@ -280,3 +280,12 @@ func (p PostgreSQLProvider) VerfiyCharacterCollation(charset, collation string)
|
|||
|
||||
return true, ""
|
||||
}
|
||||
|
||||
// ConvertTimestamp returns SQL function to correctly convert
|
||||
// ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific
|
||||
// timestamp value (e.g. 2016-09-08 06:37:23).
|
||||
// Must use ? for parameter placeholder character as DB layer
|
||||
// will convert to database specific parameter placeholder character.
|
||||
func (p PostgreSQLProvider) ConvertTimestamp() (statement string) {
|
||||
return `to_timestamp(?,'YYYY-MM-DD HH24:MI:SS')`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue