Skip to content

Commit 4a66dd7

Browse files
authored
Merge pull request #131 from dataplat/development
v0.7.1
2 parents 45a5b7b + be2691c commit 4a66dd7

11 files changed

+51
-25
lines changed

README.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# DBOps
66

7-
![dbops](https://sqlcollaborative.github.io/dbops/img/dbops.jpg)
7+
![dbops](docs/img/dbops.jpg)
88

99
DBOps is a Powershell module that provides Continuous Integration/Continuous Deployment capabilities for SQL database deployments. In addition to easy-to-use deployment functions, it provides tracking functionality, ensuring that each script is deployed only once and in due order. It will also grant you with ability to organize scripts into builds and deploy them in a repeatable manner on top of any previously deployed version.
1010

@@ -17,6 +17,7 @@ Currently supported RDBMS:
1717
* MySQL
1818

1919
## Features
20+
2021
The most notable features of the module:
2122

2223
* Reliably deploy your scripts in a consistent and repeatable manner
@@ -33,16 +34,20 @@ The most notable features of the module:
3334
* Powershell 5.0 or higher
3435

3536
## Installation
37+
3638
### Using git
39+
3740
```powershell
38-
git clone https://github.com/sqlcollaborative/dbops.git dbops
41+
git clone https://github.com/dataplat/dbops.git dbops
3942
Import-Module .\dbops
4043
```
44+
4145
Make sure to have the following modules installed as well:
4246
- [PSFramework](https://github.com/PowershellFrameworkCollective/psframework)
4347
- [ZipHelper](https://www.powershellgallery.com/packages/ziphelper) - only if you intend to run module tests
4448

4549
### Using PSGallery (Powershell 5+)
50+
4651
```powershell
4752
Install-Module dbops
4853
```
@@ -56,6 +61,7 @@ Install-Module dbops
5661
* Versioned package deployment (e.g. Octopus Deployment)
5762

5863
## Examples
64+
5965
### Simple deployments and ad-hoc queries
6066

6167
Perform plain-text script deployments using a single command:
@@ -72,9 +78,10 @@ Install-DBOScript -ScriptPath C:\temp\myscripts -SqlInstance server1 -Database M
7278
# Execute a list of files as an Ad-hoc query
7379
Get-ChildItem C:\temp\myscripts | Invoke-DBOQuery -SqlInstance server1 -Database MyDB
7480
```
81+
7582
### Package management
7683

77-
<img src="https://sqlcollaborative.github.io/dbops/img/dbops-package.jpg" alt="dbops packages" width="800"/>
84+
<img src="docs/img/dbops-package.jpg" alt="dbops packages" width="800"/>
7885

7986
Each package consists of multiple builds and can be easily deployed to the database, ensuring that each build is deployed in proper order and only once.
8087

@@ -99,6 +106,7 @@ Get-ChildItem .\myscripts | Add-DBOBuild Deploy.zip -Type New,Modified -Build 3.
99106
Expand-Archive Deploy.zip '.\MyTempFolder'
100107
.\MyTempFolder\Deploy.ps1 -SqlInstance server1 -Database MyDB
101108
```
109+
102110
### Configurations and defaults
103111

104112
There are multiple configuration options available, including:
@@ -140,7 +148,7 @@ Reset-DBODefaultSetting -Name SchemaVersionTable
140148

141149
dbops CI/CD flow assumes that each package version is built only once and deployed onto every single environment. The successfull builds should make their way as artifacts into the artifact storage, from which they would be pulled again to add new builds into the package during the next iteration.
142150

143-
<img src="https://sqlcollaborative.github.io/dbops/img/ci-cd-flow.jpg" alt="CI-CD flow" width="800"/>
151+
<img src="docs/img/ci-cd-flow.jpg" alt="CI-CD flow" width="800"/>
144152

145153
CI/CD capabilities of the module enable user to integrate SQL scripts into a package file using a single command and to store packages in a versioned package repository.
146154

@@ -172,5 +180,7 @@ Get-DBOPackageArtifact -Path myPackage.zip -Repository \\data\repo | Install-DBO
172180
* Optional rollback scripts
173181

174182
## Contacts
175-
Submitting issues - [GitHub issues](https://github.com/sqlcollaborative/dbops/issues)
176-
SQLCommunity Slack: https://sqlcommunity.slack.com #devops or @nvarscar
183+
184+
Submitting issues - [GitHub issues](https://github.com/dataplat/dbops/issues)
185+
186+
SQLCommunity Slack: https://sqlcommunity.slack.com #dbops or @nvarscar

appveyor.yml

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
build: false
44
version: 0.1.{build}
5+
only_commits:
6+
files:
7+
- bin/
8+
- functions/
9+
- internal/
10+
- src/
11+
- tests/
12+
- appveyor.yml
13+
- dbops.ps*
14+
- build.cake
515

616
#images
717

azure-main.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ trigger:
33
include:
44
- main
55
paths:
6-
exclude:
7-
- docs
8-
- README.md
6+
include:
7+
- bin
8+
- functions
9+
- internal
10+
- src
11+
- dbops.ps*
912
pr: none
1013
jobs:
1114
- job: cut_new_release_branch

azure-release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
- task: PowerShell@2
2222
displayName: Build libraries
2323
inputs:
24-
filePath: .\build.ps1
24+
filePath: .\build\build.ps1
25+
arguments: -Script .\build.cake
2526
- task: PowerShell@2
2627
displayName: Copy libraries
2728
inputs:

docs/changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Release notes for v0.7.1:
2+
- ### Adding support for underscore char in tokens (#130) by @nvarscar
13
# Release notes for v0.7.0:
24
- ### Improving schema history table - new columns (#124) by @nvarscar
35
# Release notes for v0.6.4:

internal/functions/Resolve-VariableToken.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
foreach ($obj in $InputObject) {
2525
if ($obj -is [string]) {
2626
$output = $obj
27-
foreach ($token in (Get-VariableToken -InputString $obj -RegexString $TokenRegex.Replace('token', '[a-zA-Z0-9\-.]+'))) {
27+
foreach ($token in (Get-VariableToken -InputString $obj -RegexString $TokenRegex.Replace('token', '[a-zA-Z0-9_\-.]+'))) {
2828
#Replace variables found in the config
2929
$tokenRegExString = $TokenRegex.Replace('token', [Regex]::Escape($token))
3030
if ($Runtime) {

tests/Invoke-DBOQuery.Tests.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ Describe "Invoke-DBOQuery tests" -Tag $commandName, IntegrationTests {
140140
}
141141
It "should run the query with custom variables and custom token template" {
142142
Set-PSFConfig -FullName dbops.config.variabletoken -Value '\$(token)\$'
143-
$query = "SELECT '`$Test`$' AS A, '`$Test2`$' AS B UNION ALL SELECT '3' AS A, '4' AS B"
144-
$result = Invoke-DBOQuery -Query $query -SqlInstance $script:mssqlInstance -Credential $script:mssqlCredential -As DataTable -Variables @{ Test = '1'; Test2 = '2' }
143+
$query = "SELECT '`$Test`$' AS A, '`$Test_2.1-3`$' AS B UNION ALL SELECT '3' AS A, '4' AS B"
144+
$result = Invoke-DBOQuery -Query $query -SqlInstance $script:mssqlInstance -Credential $script:mssqlCredential -As DataTable -Variables @{ Test = '1'; "Test_2.1-3" = '2' }
145145
$result.A | Should -Be '1', '3'
146146
$result.B | Should -Be '2', '4'
147147
(Get-PSFConfig -FullName dbops.config.variabletoken).ResetValue()

tests/Update-DBOSchemaTable.Tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Describe "Update-DBOSchemaTable integration tests" -Tag $commandName, Integratio
5757

5858
#Verifying SchemaVersions table
5959
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f 'SchemaVersions')
60-
$testResults.column_name | Should -Be @('Id', 'ScriptName', 'Applied', 'Checksum', 'AppliedBy', 'ExecutionTime')
60+
$testResults.column_name | Should -BeIn @('Id', 'ScriptName', 'Applied', 'Checksum', 'AppliedBy', 'ExecutionTime')
6161
}
6262
It "upgrade custom schema table" {
6363
$null = Invoke-DBOQuery @connParams -Database $newDbName -Query ($schemaTableQuery -f $logTable)
@@ -66,7 +66,7 @@ Describe "Update-DBOSchemaTable integration tests" -Tag $commandName, Integratio
6666
$result | Should -BeNullOrEmpty
6767

6868
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f $logTable)
69-
$testResults.column_name | Should -Be @('Id', 'ScriptName', 'Applied', 'Checksum', 'AppliedBy', 'ExecutionTime')
69+
$testResults.column_name | Should -BeIn @('Id', 'ScriptName', 'Applied', 'Checksum', 'AppliedBy', 'ExecutionTime')
7070
}
7171
}
7272
Context "$commandName whatif tests" {
@@ -77,7 +77,7 @@ Describe "Update-DBOSchemaTable integration tests" -Tag $commandName, Integratio
7777
$result | Should -BeNullOrEmpty
7878

7979
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f $logTable)
80-
$testResults.column_name | Should -Be @('Id', 'ScriptName', 'Applied')
80+
$testResults.column_name | Should -BeIn @('Id', 'ScriptName', 'Applied')
8181
}
8282
}
8383
}

tests/mysql/Update-DBOSchemaTable.Tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Describe "Update-DBOSchemaTable MySQL integration tests" -Tag $commandName, Inte
6161

6262
#Verifying SchemaVersions table
6363
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f 'SchemaVersions')
64-
$testResults.column_name | Should -Be @('schemaversionid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
64+
$testResults.column_name | Should -BeIn @('schemaversionid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
6565
}
6666
It "upgrade custom schema table" {
6767
$null = Invoke-DBOQuery @connParams -Database $newDbName -Query ($schemaTableQuery -f $logTable)
@@ -70,7 +70,7 @@ Describe "Update-DBOSchemaTable MySQL integration tests" -Tag $commandName, Inte
7070
$result | Should -BeNullOrEmpty
7171

7272
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f $logTable)
73-
$testResults.column_name | Should -Be @('schemaversionid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
73+
$testResults.column_name | Should -BeIn @('schemaversionid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
7474
}
7575
}
7676
Context "$commandName whatif tests" {
@@ -81,7 +81,7 @@ Describe "Update-DBOSchemaTable MySQL integration tests" -Tag $commandName, Inte
8181
$result | Should -BeNullOrEmpty
8282

8383
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f $logTable)
84-
$testResults.column_name | Should -Be @('schemaversionid', 'scriptname', 'applied')
84+
$testResults.column_name | Should -BeIn @('schemaversionid', 'scriptname', 'applied')
8585
}
8686
}
8787
}

tests/oracle/Update-DBOSchemaTable.Tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Describe "Update-DBOSchemaTable Oracle integration tests" -Tag $commandName, Int
9191

9292
#Verifying SchemaVersions table
9393
$testResults = Invoke-DBOQuery @connParams -Query ($verificationQuery -f 'SCHEMAVERSIONS')
94-
$testResults.COLUMN_NAME | Should -Be @('SCHEMAVERSIONID', 'SCRIPTNAME', 'APPLIED', 'CHECKSUM', 'APPLIEDBY', 'EXECUTIONTIME')
94+
$testResults.COLUMN_NAME | Should -BeIn @('SCHEMAVERSIONID', 'SCRIPTNAME', 'APPLIED', 'CHECKSUM', 'APPLIEDBY', 'EXECUTIONTIME')
9595
}
9696
It "upgrade custom schema table" {
9797
$null = Invoke-DBOQuery @connParams -Query ($schemaTableQuery -f $logTable)
@@ -100,7 +100,7 @@ Describe "Update-DBOSchemaTable Oracle integration tests" -Tag $commandName, Int
100100
$result | Should -BeNullOrEmpty
101101

102102
$testResults = Invoke-DBOQuery @connParams -Query ($verificationQuery -f $logTable)
103-
$testResults.COLUMN_NAME | Should -Be @('SCHEMAVERSIONID', 'SCRIPTNAME', 'APPLIED', 'CHECKSUM', 'APPLIEDBY', 'EXECUTIONTIME')
103+
$testResults.COLUMN_NAME | Should -BeIn @('SCHEMAVERSIONID', 'SCRIPTNAME', 'APPLIED', 'CHECKSUM', 'APPLIEDBY', 'EXECUTIONTIME')
104104
}
105105
}
106106
Context "$commandName whatif tests" {
@@ -111,7 +111,7 @@ Describe "Update-DBOSchemaTable Oracle integration tests" -Tag $commandName, Int
111111
$result | Should -BeNullOrEmpty
112112

113113
$testResults = Invoke-DBOQuery @connParams -Query ($verificationQuery -f $logTable)
114-
$testResults.COLUMN_NAME | Should -Be @('SCHEMAVERSIONID', 'SCRIPTNAME', 'APPLIED')
114+
$testResults.COLUMN_NAME | Should -BeIn @('SCHEMAVERSIONID', 'SCRIPTNAME', 'APPLIED')
115115
}
116116
}
117117
}

tests/postgresql/Update-DBOSchemaTable.Tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Describe "Update-DBOSchemaTable Postgresql integration tests" -Tag $commandName,
6565

6666
#Verifying SchemaVersions table
6767
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f 'SchemaVersions')
68-
$testResults.column_name | Should -Be @('schemaversionsid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
68+
$testResults.column_name | Should -BeIn @('schemaversionsid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
6969
}
7070
It "upgrade custom schema table" {
7171
$null = Invoke-DBOQuery @connParams -Database $newDbName -Query ($schemaTableQuery -f $logTable)
@@ -74,7 +74,7 @@ Describe "Update-DBOSchemaTable Postgresql integration tests" -Tag $commandName,
7474
$result | Should -BeNullOrEmpty
7575

7676
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f $logTable)
77-
$testResults.column_name | Should -Be @('schemaversionsid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
77+
$testResults.column_name | Should -BeIn @('schemaversionsid', 'scriptname', 'applied', 'checksum', 'appliedby', 'executiontime')
7878
}
7979
}
8080
Context "$commandName whatif tests" {
@@ -85,7 +85,7 @@ Describe "Update-DBOSchemaTable Postgresql integration tests" -Tag $commandName,
8585
$result | Should -BeNullOrEmpty
8686

8787
$testResults = Invoke-DBOQuery @connParams -Database $newDbName -Query ($verificationQuery -f $logTable)
88-
$testResults.column_name | Should -Be @('schemaversionsid', 'scriptname', 'applied')
88+
$testResults.column_name | Should -BeIn @('schemaversionsid', 'scriptname', 'applied')
8989
}
9090
}
9191
}

0 commit comments

Comments
 (0)