1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Create tables

Script to create tables with correct data types in SQL Server 2016 and above.

Search table not included.
This commit is contained in:
Harvey Kandola 2019-03-29 16:42:49 +00:00
parent 80aab3ce99
commit 9ec858286f
5 changed files with 1224 additions and 717 deletions

View file

@ -51,9 +51,17 @@ type SQLServerProvider struct {
// SetSQLServerProvider creates PostgreSQL provider.
//
// Driver for Golang: https://github.com/denisenkom/go-mssqldb
// Docker Linux testing: https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017
// docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Passw0rd' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
// Useful links:
//
// Driver for Golang:
// https://github.com/denisenkom/go-mssqldb
// Docker Linux testing:
// https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017
// docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Passw0rd' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
// JSON types:
// https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-2017
//
// Supports 2016, 2017 and 2019.
func SetSQLServerProvider(r *env.Runtime, s *store.Store) {
// Set up provider specific details.
r.StoreProvider = SQLServerProvider{
@ -232,8 +240,7 @@ func (p SQLServerProvider) QueryRecordVersionUpgrade(version int) string {
// Make record that holds new database version number.
json := fmt.Sprintf("{\"database\": \"%d\"}", version)
return fmt.Sprintf(`INSERT INTO dmz_config (c_key,c_config) VALUES ('META','%s')
ON CONFLICT (c_key) DO UPDATE SET c_config='%s' WHERE dmz_config.c_key='META'`, json, json)
return fmt.Sprintf(`UPDATE dmz_config SET c_config='%s' WHERE c_key='META'`, json)
}
// QueryRecordVersionUpgradeLegacy returns database specific insert statement