Skip to content

Commit

Permalink
Integrate schema export with existing export flow
Browse files Browse the repository at this point in the history
Schema export is now running as a part of the export process. #415
  • Loading branch information
joyfullservice committed Jul 21, 2023
1 parent 4377d0d commit 4fbda90
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions Version Control.accda.src/modules/modConstants.bas
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ End Enum

' Database server types for external databases
Public Enum eDatabaseServerType
estUnknown
estMsSql
estMySql
End Enum
Expand Down
65 changes: 65 additions & 0 deletions Version Control.accda.src/modules/modImportExport.bas
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ Public Sub ExportSource(blnFullExport As Boolean, Optional intFilter As eContain
Perf.OperationEnd
End If

' Export any external database schemas
ExportSchemas blnFullExport

' Finish header section
Log.Spacer
Log.Add "Scanning " & IIf(blnFullExport, "source files...", "for changes...")
Expand Down Expand Up @@ -577,6 +580,68 @@ CleanUp:
End Sub


'---------------------------------------------------------------------------------------
' Procedure : ExportSchemas
' Author : Adam Waller
' Date : 7/21/2023
' Purpose : Export any external database schemas configured in options
'---------------------------------------------------------------------------------------
'
Public Sub ExportSchemas(blnFullExport As Boolean)

Dim varKey As Variant
Dim strName As String
Dim strType As String
Dim cSchema As IDbSchema
Dim dParams As Dictionary
Dim strFile As String

' Skip this section if there are no connections defined.
If Options.SchemaExports.Count = 0 Then Exit Sub

' Loop through schemas
Log.Spacer
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 = CloneDictionary(Options.SchemaExports(varKey))
dParams("Name") = strName

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
With New clsDotEnv
.LoadFromFile strFile
.MergeIntoDictionary dParams, False
End With
cSchema.Initialize dParams
cSchema.Export blnFullExport
End If
Perf.CategoryEnd
Next varKey
Perf.OperationEnd

End Sub


'---------------------------------------------------------------------------------------
' Procedure : Build (Full build or Merge Build)
' Author : Adam Waller
Expand Down

0 comments on commit 4fbda90

Please sign in to comment.