Skip to content

Commit

Permalink
Implement option to disable a schema sync
Browse files Browse the repository at this point in the history
This allows you to enable or disable a particular external database connection. #415
  • Loading branch information
joyfullservice committed Aug 1, 2023
1 parent 52842f2 commit 93956ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
30 changes: 18 additions & 12 deletions Version Control.accda.src/modules/modImportExport.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 9 additions & 8 deletions Version Control.accda.src/modules/modVCSUtility.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93956ee

Please sign in to comment.