Skip to content

Commit 9357570

Browse files
chore: bump mssql image to 2025 (#9987)
* chore: bump mssql image to 2025 * Add alter DB query before dropping database Co-authored-by: michalsn <michal@sniatala.pl> --------- Co-authored-by: michalsn <michal@sniatala.pl>
1 parent 888b401 commit 9357570

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

.github/workflows/reusable-phpunit-test.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ env:
6565
jobs:
6666
tests:
6767
name: ${{ inputs.job-name }}
68-
runs-on: ubuntu-22.04
68+
runs-on: ubuntu-24.04
6969

7070
# Service containers cannot be extracted to caller workflows yet
7171
services:
@@ -97,7 +97,7 @@ jobs:
9797
--health-retries=3
9898
9999
mssql:
100-
image: mcr.microsoft.com/mssql/server:2022-latest
100+
image: mcr.microsoft.com/mssql/server:2025-CU2-ubuntu-24.04
101101
env:
102102
MSSQL_SA_PASSWORD: 1Secure*Password1
103103
ACCEPT_EULA: Y
@@ -140,15 +140,32 @@ jobs:
140140
- 11211:11211
141141

142142
steps:
143+
- name: Install mssql-tools on runner
144+
if: ${{ inputs.db-platform == 'SQLSRV' }}
145+
run: |
146+
# Detect Ubuntu version used by the runner (fallback to 24.04)
147+
DISTRO=$(lsb_release -rs 2>/dev/null || echo '24.04')
148+
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
149+
curl -sSL https://packages.microsoft.com/config/ubuntu/${DISTRO}/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
150+
sudo apt-get update
151+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev
152+
153+
# Make sqlcmd available to subsequent steps
154+
echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH
155+
143156
- name: Create database for MSSQL Server
144157
if: ${{ inputs.db-platform == 'SQLSRV' }}
145-
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test COLLATE Latin1_General_100_CS_AS_SC_UTF8"
158+
run: |
159+
sqlcmd -S 127.0.0.1 \
160+
-U sa -P 1Secure*Password1 \
161+
-N -C \
162+
-Q "CREATE DATABASE test COLLATE Latin1_General_100_CS_AS_SC_UTF8"
146163
147164
- name: Install latest ImageMagick
148165
if: ${{ contains(inputs.extra-extensions, 'imagick') }}
149166
run: |
150167
sudo apt-get update
151-
sudo apt-get install --reinstall libgs9-common fonts-noto-mono libgs9:amd64 libijs-0.35:amd64 fonts-urw-base35 ghostscript poppler-data libjbig2dec0:amd64 libopenjp2-7:amd64 fonts-droid-fallback fonts-dejavu-core
168+
sudo apt-get install --reinstall fonts-noto-mono libijs-0.35:amd64 fonts-urw-base35 ghostscript poppler-data libjbig2dec0:amd64 libopenjp2-7:amd64 fonts-droid-fallback fonts-dejavu-core
152169
sudo apt-get install -y gsfonts libmagickwand-dev imagemagick
153170
sudo apt-get install --fix-broken
154171

.github/workflows/test-phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
# in the caller workflow are not propagated to the called workflow.
4242
coverage-php-version:
4343
name: Setup PHP Version for Code Coverage
44-
runs-on: ubuntu-22.04
44+
runs-on: ubuntu-24.04
4545
outputs:
4646
version: ${{ steps.coverage-php-version.outputs.version }}
4747
steps:

system/Database/SQLSRV/Forge.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,25 @@ public function createDatabase(string $dbName, bool $ifNotExists = false): bool
168168
}
169169
}
170170

171+
/**
172+
* {@inheritDoc}
173+
*
174+
* @see https://stackoverflow.com/questions/7469130/cannot-drop-database-because-it-is-currently-in-use
175+
*/
176+
public function dropDatabase(string $dbName): bool
177+
{
178+
try {
179+
$this->db->query(sprintf(
180+
'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE',
181+
$this->db->escapeIdentifier($dbName),
182+
));
183+
} catch (DatabaseException) {
184+
// no-op
185+
}
186+
187+
return parent::dropDatabase($dbName);
188+
}
189+
171190
/**
172191
* CREATE TABLE attributes
173192
*/

0 commit comments

Comments
 (0)