Skip to content

Commit

Permalink
Merge branch 'development' into shawn/syncpwd
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee authored Sep 28, 2023
2 parents 2e5f42f + 776a016 commit b8f8877
Show file tree
Hide file tree
Showing 330 changed files with 5,003 additions and 913 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gallery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: dbatools.library:2023.5.5
modules-to-cache: dbatools.library:2023.9.21

- name: Download dbatools from Gallery
run: |
Expand Down
152 changes: 152 additions & 0 deletions .github/workflows/integration-tests-repl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Run Replication Tests
on: [push]
defaults:
run:
shell: pwsh
jobs:
repl-tests-part1:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

steps:
- uses: actions/checkout@v3

- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: dbatools.library:2023.5.5

- name: Set encryption values
run: |
Import-Module ./dbatools.psd1 -Force
Set-DbatoolsConfig -FullName sql.connection.trustcert -Value $true -Register
Set-DbatoolsConfig -FullName sql.connection.encrypt -Value Optional -Register
Get-DbatoolsConfigValue -FullName sql.connection.encrypt | Write-Warning
- name: Setup docker images
run: |
# create a shared network
docker network create localnet
# Expose engine and endpoint then setup a shared path for migrations
docker run -p 1433:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet -d dbatools/sqlinstance
# Expose second engine and endpoint on different port
docker run -p 14333:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet -d dbatools/sqlinstance2
- name: Add hostname to hosts file
run: |
echo "127.0.0.1 mssql1 mssql2" | sudo tee -a /etc/hosts
- name: 👥 Clone appveyor repo
working-directory: /tmp
run: |
gh repo clone dataplat/appveyor-lab
- name: Setup Replication
run: |
Import-Module ./dbatools.psd1 -Force
# need some folders for our repl stuff
docker exec mssql1 mkdir /shared/data /shared/repldata /var/opt/mssql/ReplData
- name: Run replication tests part 1
run: |
Import-Module ./dbatools.psd1 -Force
$null = Invoke-Pester ./tests/gh-actions-repl-1.ps1 -Output Detailed -PassThru -Verbose
repl-tests-part2:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

steps:
- uses: actions/checkout@v3

- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: dbatools.library:2023.5.5

- name: Set encryption values
run: |
Import-Module ./dbatools.psd1 -Force
Set-DbatoolsConfig -FullName sql.connection.trustcert -Value $true -Register
Set-DbatoolsConfig -FullName sql.connection.encrypt -Value Optional -Register
Get-DbatoolsConfigValue -FullName sql.connection.encrypt | Write-Warning
- name: Setup docker images
run: |
# create a shared network
docker network create localnet
# Expose engine and endpoint then setup a shared path for migrations
docker run -p 1433:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet -d dbatools/sqlinstance
# Expose second engine and endpoint on different port
docker run -p 14333:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet -d dbatools/sqlinstance2
- name: Add hostname to hosts file
run: |
echo "127.0.0.1 mssql1 mssql2" | sudo tee -a /etc/hosts
- name: 👥 Clone appveyor repo
working-directory: /tmp
run: |
gh repo clone dataplat/appveyor-lab
- name: Setup Replication
run: |
Import-Module ./dbatools.psd1 -Force
# need some folders for our repl stuff
docker exec mssql1 mkdir /shared/data /shared/repldata /var/opt/mssql/ReplData
- name: Run replication tests part 2
run: |
Import-Module ./dbatools.psd1 -Force
$null = Invoke-Pester ./tests/gh-actions-repl-2.ps1 -Output Detailed -PassThru -Verbose
repl-tests-part3:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

steps:
- uses: actions/checkout@v3

- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: dbatools.library:2023.5.5

- name: Set encryption values
run: |
Import-Module ./dbatools.psd1 -Force
Set-DbatoolsConfig -FullName sql.connection.trustcert -Value $true -Register
Set-DbatoolsConfig -FullName sql.connection.encrypt -Value Optional -Register
Get-DbatoolsConfigValue -FullName sql.connection.encrypt | Write-Warning
- name: Setup docker images
run: |
# create a shared network
docker network create localnet
# Expose engine and endpoint then setup a shared path for migrations
docker run -p 1433:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet -d dbatools/sqlinstance
# Expose second engine and endpoint on different port
docker run -p 14333:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet -d dbatools/sqlinstance2
- name: Add hostname to hosts file
run: |
echo "127.0.0.1 mssql1 mssql2" | sudo tee -a /etc/hosts
- name: 👥 Clone appveyor repo
working-directory: /tmp
run: |
gh repo clone dataplat/appveyor-lab
- name: Setup Replication
run: |
Import-Module ./dbatools.psd1 -Force
# need some folders for our repl stuff
docker exec mssql1 mkdir /shared/data /shared/repldata /var/opt/mssql/ReplData
- name: Run replication tests part 3
run: |
Import-Module ./dbatools.psd1 -Force
Invoke-Pester ./tests/gh-actions-repl-3.ps1 -Output Detailed -PassThru -Verbose
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: dbatools.library:2023.5.5
modules-to-cache: dbatools.library:2023.9.21

- name: Set encryption values
run: |
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
uses: potatoqualitee/[email protected]
with:
shell: powershell, pwsh
modules-to-cache: dbatools.library:2023.5.5
modules-to-cache: dbatools.library:2023.9.21

- name: Install SQL Server localdb
uses: potatoqualitee/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/xplat-import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: dbatools.library:2023.5.5
modules-to-cache: dbatools.library:2023.9.21

- name: Perform the import
shell: pwsh
Expand Down
99 changes: 99 additions & 0 deletions ReplicationDemo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# dbatools 💜 dbatools

##############################
# create docker environment
##############################
# create a shared network
docker network create localnet

# Expose engines and setup shared path for migrations
docker run -p 2500:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet -d dbatools/sqlinstance
docker run -p 2600:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet -d dbatools/sqlinstance2

# create the repl folder
docker exec mssql1 mkdir /var/opt/mssql/ReplData

# also need these folders for setting up replication
docker exec mssql1 mkdir /shared/data /shared/repldata

##############################

# import out version of the module
cd C:\GitHub\DMM-GitHub\dbatools
Import-Module .\dbatools.psd1

# lets save the password for connecting to containers because I'm lazy
$securePassword = ('dbatools.IO' | ConvertTo-SecureString -AsPlainText -Force)
$credential = New-Object System.Management.Automation.PSCredential('sqladmin', $securePassword)

$PSDefaultParameterValues = @{
"*:SqlCredential" = $credential
"*:DestinationCredential" = $credential
"*:DestinationSqlCredential" = $credential
"*:SourceSqlCredential" = $credential
"*:PublisherSqlCredential" = $credential
}

# what do we have so far
Get-DbaReplServer -SqlInstance mssql1
Get-DbaReplDistributor -SqlInstance mssql1
Get-DbaReplPublisher -SqlInstance mssql1

# enable distribution
Enable-DbaReplDistributor -SqlInstance mssql1

# enable publishing
Enable-DbaReplPublishing -SqlInstance mssql1

# create a transactional publication using splat format
$pub = @{
SqlInstance = 'mssql1'
Database = 'pubs'
PublicationName = 'testPub'
Type = 'Transactional'
}
New-DbaReplPublication @pub

# add an article to the publication
$article = @{
SqlInstance = 'mssql1'
Database = 'pubs'
PublicationName = 'testpub'
Name = 'authors'
}
Add-DbaReplArticle @article

# create a pubs database on mssql2 to replicate to
New-DbaDatabase -SqlInstance mssql2 -Name pubs

# if you don't the New-DbaReplSubscription command will create the database for you

# add a subscription to the publication
$sub = @{
SqlInstance = 'mssql2'
Database = 'pubs'
PublicationDatabase = 'pubs'
PublisherSqlInstance = 'mssql1'
PublicationName = 'testpub'
Type = 'Push'
SubscriptionSqlCredential = $credential

}
New-DbaReplSubscription @sub

# creates the snapshot job with a daily schedule at 8am - is that expected? good default?
# should adding a subscription kick off snapshot? should that be an param -StartSnapshotNow -- yes
# create that without a schedule by default maybe a param for a schedule
#

# stats on the subscription - in the distribution database
# could we make a command to get stats





## when adding an article - we need the options
# - action if name is in use 'drop existing object and create new'
# copy nonclusterd indexes
# nuno
22 changes: 21 additions & 1 deletion bin/dbatools-buildref-index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"LastUpdated": "2023-06-15T00:00:00",
"LastUpdated": "2023-09-14T00:00:00",
"Data": [
{
"Version": "8.0.47",
Expand Down Expand Up @@ -4510,6 +4510,11 @@
"Version": "15.0.4316",
"KBList": "5025808"
},
{
"CU": "CU22",
"Version": "15.0.4322",
"KBList": "5027702"
},
{
"Version": "16.0.100",
"Name": "2022"
Expand Down Expand Up @@ -4555,6 +4560,21 @@
"CU": "CU5",
"Version": "16.0.4045",
"KBList": "5026806"
},
{
"CU": "CU6",
"Version": "16.0.4055",
"KBList": "5027505"
},
{
"CU": "CU7",
"Version": "16.0.4065",
"KBList": "5028743"
},
{
"CU": "CU8",
"Version": "16.0.4075",
"KBList": "5029666"
}
]
}
Binary file modified bin/dbatools-index.json
Binary file not shown.
10 changes: 5 additions & 5 deletions bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2012 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 5, 2023
-- Last Modified: September 1, 2023
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -1654,10 +1654,10 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE);


-- Get Schema names, Table names, object size, row counts, and compression status for clustered index or heap (Query 64) (Table Sizes)
SELECT DB_NAME(DB_ID()) AS [Database Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name],
SELECT DB_NAME(DB_ID()) AS [Database Name], SCHEMA_NAME(o.schema_id) AS [Schema Name],
OBJECT_NAME(p.object_id) AS [Table Name],
CAST(SUM(ps.reserved_page_count) * 8.0 / 1024 AS DECIMAL(19,2)) AS [Object Size (MB)],
SUM(p.Rows) AS [Row Count],
SUM(p.rows) AS [Row Count],
p.data_compression_desc AS [Compression Type]
FROM sys.objects AS o WITH (NOLOCK)
INNER JOIN sys.partitions AS p WITH (NOLOCK)
Expand All @@ -1667,8 +1667,8 @@ ON p.object_id = ps.object_id
WHERE ps.index_id < 2 -- ignore the partitions from the non-clustered indexes if any
AND p.index_id < 2 -- ignore the partitions from the non-clustered indexes if any
AND o.type_desc = N'USER_TABLE'
GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, ps.reserved_page_count, p.data_compression_desc
ORDER BY SUM(ps.reserved_page_count) DESC, SUM(p.Rows) DESC OPTION (RECOMPILE);
GROUP BY SCHEMA_NAME(o.schema_id), p.object_id, ps.reserved_page_count, p.data_compression_desc
ORDER BY SUM(ps.reserved_page_count) DESC, SUM(p.rows) DESC OPTION (RECOMPILE);
------

-- Gives you an idea of table sizes, and possible data compression opportunities
Expand Down
10 changes: 5 additions & 5 deletions bin/diagnosticquery/SQLServerDiagnosticQueries_2014.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

-- SQL Server 2014 Diagnostic Information Queries
-- Glenn Berry
-- Last Modified: June 5, 2023
-- Last Modified: September 1, 2023
-- https://glennsqlperformance.com/
-- https://sqlserverperformance.wordpress.com/
-- YouTube: https://bit.ly/2PkoAM1
Expand Down Expand Up @@ -1704,10 +1704,10 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE);


-- Get Schema names, Table names, object size, row counts, and compression status for clustered index or heap (Query 66) (Table Sizes)
SELECT DB_NAME(DB_ID()) AS [Database Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name],
SELECT DB_NAME(DB_ID()) AS [Database Name], SCHEMA_NAME(o.schema_id) AS [Schema Name],
OBJECT_NAME(p.object_id) AS [Table Name],
CAST(SUM(ps.reserved_page_count) * 8.0 / 1024 AS DECIMAL(19,2)) AS [Object Size (MB)],
SUM(p.Rows) AS [Row Count],
SUM(p.rows) AS [Row Count],
p.data_compression_desc AS [Compression Type]
FROM sys.objects AS o WITH (NOLOCK)
INNER JOIN sys.partitions AS p WITH (NOLOCK)
Expand All @@ -1717,8 +1717,8 @@ ON p.object_id = ps.object_id
WHERE ps.index_id < 2 -- ignore the partitions from the non-clustered indexes if any
AND p.index_id < 2 -- ignore the partitions from the non-clustered indexes if any
AND o.type_desc = N'USER_TABLE'
GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, ps.reserved_page_count, p.data_compression_desc
ORDER BY SUM(ps.reserved_page_count) DESC, SUM(p.Rows) DESC OPTION (RECOMPILE);
GROUP BY SCHEMA_NAME(o.schema_id), p.object_id, ps.reserved_page_count, p.data_compression_desc
ORDER BY SUM(ps.reserved_page_count) DESC, SUM(p.rows) DESC OPTION (RECOMPILE);
------

-- Gives you an idea of table sizes, and possible data compression opportunities
Expand Down
Loading

0 comments on commit b8f8877

Please sign in to comment.