-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
102 lines (86 loc) · 3.88 KB
/
docker-compose.yml
File metadata and controls
102 lines (86 loc) · 3.88 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
services:
mssql:
image: mcr.microsoft.com/mssql/server:2025-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Test1234!
healthcheck:
test: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "Test1234!" -Q "SELECT 1" -C || exit 1
interval: 10s
timeout: 3s
retries: 10
start_period: 5s
mssql_init:
image: alpine:latest
depends_on:
mssql:
condition: service_healthy
volumes:
- ./SQLSchemaCompare.Test/Datasources:/scripts
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
apk add --no-cache curl tar bzip2
curl -L https://github.com/microsoft/go-sqlcmd/releases/download/v1.10.0/sqlcmd-linux-amd64.tar.bz2 | tar -xj -C /usr/local/bin
sqlcmd -C -S mssql -U sa -P "Test1234!" -Q "DROP DATABASE IF EXISTS sakila_source"
sqlcmd -C -S mssql -U sa -P "Test1234!" -Q "CREATE DATABASE sakila_source"
sqlcmd -C -S mssql -U sa -P "Test1234!" -d sakila_source -i /scripts/sakila-schema-microsoftsql.sql
sqlcmd -C -S mssql -U sa -P "Test1234!" -Q "DROP DATABASE IF EXISTS sakila_target"
sqlcmd -C -S mssql -U sa -P "Test1234!" -Q "CREATE DATABASE sakila_target"
sqlcmd -C -S mssql -U sa -P "Test1234!" -d sakila_target -i /scripts/sakila-schema-microsoftsql.sql
sqlcmd -C -S mssql -U sa -P "Test1234!" -d sakila_target -Q "ALTER TABLE business.staff DROP COLUMN last_name"
sql_schema_compare_test:
build:
context: .
dockerfile: ./SQLSchemaCompare.CLI/Dockerfile
depends_on:
mssql_init:
condition: service_completed_successfully
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
expected=$(printf "ALTER TABLE [business].[staff] ADD [last_name] [varchar](45) NOT NULL\nGO")
projectFile=$(mktemp)
{
echo '<?xml version="1.0" encoding="utf-8"?>'
echo '<CompareProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'
echo ' <SourceProviderOptions xsi:type="MicrosoftSqlDatabaseProviderOptions">'
echo ' <UseConnectionString>true</UseConnectionString>'
echo ' <ConnectionString>Server=mssql;Database=sakila_source;User ID=sa;Password=Test1234!;TrustServerCertificate=True;</ConnectionString>'
echo ' </SourceProviderOptions>'
echo ' <TargetProviderOptions xsi:type="MicrosoftSqlDatabaseProviderOptions">'
echo ' <UseConnectionString>true</UseConnectionString>'
echo ' <ConnectionString>Server=mssql;Database=sakila_target;User ID=sa;Password=Test1234!;TrustServerCertificate=True;</ConnectionString>'
echo ' </TargetProviderOptions>'
echo ' <Options>'
echo ' </Options>'
echo '</CompareProject>'
} > "$$projectFile"
outputFile=$(mktemp)
/app/TiCodeX.SQLSchemaCompare.CLI -p $$projectFile -o $$outputFile
output=$(cat $$outputFile)
if [ "$$output" != "$$expected" ]; then
echo "Output does not match expected"
echo "Expected:"
printf "%s" "$$expected" | hexdump -C
echo "Actual:"
printf "%s" "$$output" | hexdump -C
exit 1
fi
outputFile=$(mktemp)
/app/TiCodeX.SQLSchemaCompare.CLI \
--type MicrosoftSql \
--source 'Server=mssql;Database=sakila_source;User ID=sa;Password=Test1234!;TrustServerCertificate=True;' \
--target 'Server=mssql;Database=sakila_target;User ID=sa;Password=Test1234!;TrustServerCertificate=True;' \
-o $$outputFile
output=$(cat $$outputFile)
if [ "$$output" != "$$expected" ]; then
echo "Output does not match expected"
echo "Expected:"
printf "%s" "$$expected" | hexdump -C
echo "Actual:"
printf "%s" "$$output" | hexdump -C
exit 1
fi