From 93956ee3c206559a0656990b086a22d5cbfa963c Mon Sep 17 00:00:00 2001 From: joyfullservice Date: Tue, 1 Aug 2023 14:49:39 -0500 Subject: [PATCH] Implement option to disable a schema sync This allows you to enable or disable a particular external database connection. #415 --- .../modules/modImportExport.bas | 30 +++++++++++-------- .../modules/modVCSUtility.bas | 17 ++++++----- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Version Control.accda.src/modules/modImportExport.bas b/Version Control.accda.src/modules/modImportExport.bas index 9bbdb351..bcc06200 100644 --- a/Version Control.accda.src/modules/modImportExport.bas +++ b/Version Control.accda.src/modules/modImportExport.bas @@ -606,27 +606,33 @@ Public Sub ExportSchemas(blnFullExport As Boolean) Log.Add "Scanning external databases..." Perf.OperationStart "Scan External Databases" For Each varKey In Options.SchemaExports.Keys - Select Case Options.SchemaExports(varKey)("DatabaseType") - Case eDatabaseServerType.estMsSql - strType = " (MSSQL)" - Set cSchema = New clsSchemaMsSql - Case eDatabaseServerType.estMySql - strType = " (MySQL)" - 'Set cSchema = New clsSchemaMySql - End Select strName = varKey - Log.Add " - " & strName & strType - Perf.CategoryStart strName & strType - Log.Flush ' Load parameters for initializing the connection Set dParams = GetSchemaInitParams(strName) - If dParams("Connect") = vbNullString Then + If dParams("Enabled") = False Then + Log.Add " - " & strName & " - Connection disabled", False + ElseIf dParams("Connect") = vbNullString Then + Log.Add " - " & strName, False Log.Add " No connection string found. (.env)", , , "Red", , True Log.Error eelWarning, "File not found: " & strFile, ModuleName & ".ExportSchemas" Log.Add "Set the connection string for this external database connection in VCS options to automatically create this file.", False Log.Add "(This file may contain authentication credentials and should be excluded from version control.)", False Else + ' Show server type along with name + Select Case Options.SchemaExports(varKey)("DatabaseType") + Case eDatabaseServerType.estMsSql + strType = " (MSSQL)" + Set cSchema = New clsSchemaMsSql + Case eDatabaseServerType.estMySql + strType = " (MySQL)" + 'Set cSchema = New clsSchemaMySql + End Select + Log.Add " - " & strName & strType + Perf.CategoryStart strName & strType + Log.Flush + + ' Export/sync the server objects cSchema.Initialize dParams cSchema.Export blnFullExport lngCount = cSchema.ObjectCount(True) diff --git a/Version Control.accda.src/modules/modVCSUtility.bas b/Version Control.accda.src/modules/modVCSUtility.bas index 758c4043..201ce9d4 100644 --- a/Version Control.accda.src/modules/modVCSUtility.bas +++ b/Version Control.accda.src/modules/modVCSUtility.bas @@ -905,17 +905,18 @@ Public Function GetSchemaInitParams(strName As String) As Dictionary Dim strFile As String ' Load parameters for initializing the connection - Set dParams = CloneDictionary(Options.SchemaExports(strName)) + If Options.SchemaExports.Exists(strName) Then + Set dParams = CloneDictionary(Options.SchemaExports(strName)) + Else + ' Could be a new schema not yet saved + Set dParams = New Dictionary + dParams.CompareMode = TextCompare + End If dParams("Name") = strName + ' Check for `Connect` or other parameters in .env file strFile = BuildPath2(Options.GetExportFolder & "databases", GetSafeFileName(strName), ".env") - If Not FSO.FileExists(strFile) Then - Log.Add " No connection string found. (.env)", , , "Red", , True - Log.Error eelWarning, "File not found: " & strFile, ModuleName & ".ExportSchemas" - Log.Add "Set the connection string for this external database connection in VCS options to automatically create this file.", False - Log.Add "(This file may contain authentication credentials and should be excluded from version control.)", False - Else - ' Use .env file to initialize connection + If FSO.FileExists(strFile) Then With New clsDotEnv .LoadFromFile strFile .MergeIntoDictionary dParams, False