Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit ade6dcb

Browse files
fix: database creation, create statement exit fix
1 parent 5fb616a commit ade6dcb

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

database/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
FROM mcr.microsoft.com/mssql-tools
1+
FROM mcr.microsoft.com/mssql-tools:latest
22

3-
RUN useradd -m -s /bin/bash nonroot
43

54
WORKDIR /database
65
COPY db-setup-entrypoint.sh /database/
6+
COPY create_database_statement.sql /database/
7+
RUN chmod +x /database/db-setup-entrypoint.sh
78

8-
RUN chmod +x /database/db-setup-entrypoint.sh && \
9-
chown -R nonroot:nonroot /database
10-
11-
USER nonroot
129

1310
ENTRYPOINT ["/database/db-setup-entrypoint.sh"]
11+
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
USE master;
22
GO
33

4+
-- Check if database exists and create it if it doesn't
45
IF NOT EXISTS (
56
SELECT name
67
FROM sys.databases
78
WHERE name = N'ServiceLayer'
89
)
9-
CREATE DATABASE [Test];
10+
BEGIN
11+
CREATE DATABASE [ServiceLayer];
12+
END
1013
GO
1114

12-
IF SERVERPROPERTY('ProductVersion') > '12'
15+
USE [ServiceLayer];
16+
GO
17+
18+
-- Only try to set QUERY_STORE if SQL Server version is higher than 12 (SQL 2014)
19+
IF CAST(SERVERPROPERTY('ProductVersion') AS NVARCHAR(128)) > '12'
20+
BEGIN
1321
ALTER DATABASE [ServiceLayer] SET QUERY_STORE = ON;
22+
END
1423
GO

0 commit comments

Comments
 (0)