-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathinit-sql-server.sh
More file actions
27 lines (19 loc) · 801 Bytes
/
init-sql-server.sh
File metadata and controls
27 lines (19 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# Start SQL Server in background
/opt/mssql/bin/sqlservr &
# Wait for SQL Server to be ready
echo "Waiting for SQL Server to start..."
until /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -C -Q "SELECT 1" &> /dev/null
do
echo "SQL Server is starting up..."
sleep 2
done
echo "SQL Server is ready!"
# Create database and run DDL
echo "Creating database and running init scripts..."
/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -C -Q "CREATE DATABASE eventstore"
# -I enables QUOTED_IDENTIFIER (required for JSON INDEX)
/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -C -I -d eventstore -i /init/sql-server-event-store.ddl
echo "Database initialized successfully!"
# Keep container running
wait