Merge branch 'visualbasic/migration' of ssh://git.internal.romcomp.com:2222/jorge.burgos/rc-migration-tests into visualbasic/migration

This commit is contained in:
Ubuntu 2025-02-04 02:21:14 +00:00
commit 17fb400150
2 changed files with 77 additions and 11 deletions

View File

@ -8,23 +8,37 @@ GO
USE [st-database]
GO
-- Create schemas if they don't exist
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'dbo')
EXEC('CREATE SCHEMA [dbo]')
GO
-- Create schemas (excluding dbo since it already exists)
DECLARE @SQL nvarchar(max)
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'fp')
EXEC('CREATE SCHEMA [fp]')
GO
BEGIN
SET @SQL = 'CREATE SCHEMA fp AUTHORIZATION dbo'
EXEC sp_executesql @SQL
PRINT 'Created schema fp'
END
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'fw')
EXEC('CREATE SCHEMA [fw]')
GO
BEGIN
SET @SQL = 'CREATE SCHEMA fw AUTHORIZATION dbo'
EXEC sp_executesql @SQL
PRINT 'Created schema fw'
END
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'int')
EXEC('CREATE SCHEMA [int]')
GO
BEGIN
SET @SQL = 'CREATE SCHEMA int AUTHORIZATION dbo'
EXEC sp_executesql @SQL
PRINT 'Created schema int'
END
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'ob')
EXEC('CREATE SCHEMA [ob]')
BEGIN
SET @SQL = 'CREATE SCHEMA ob AUTHORIZATION dbo'
EXEC sp_executesql @SQL
PRINT 'Created schema ob'
END
-- Verify schemas
SELECT name FROM sys.schemas WHERE name IN ('fp', 'fw', 'int', 'ob')
GO

View File

@ -0,0 +1,52 @@
#!/bin/bash
# Start SQL Server
/opt/mssql/bin/sqlservr &
# Wait for SQL Server to start
echo "Waiting for SQL Server to start..."
sleep 30s
# Initialize database
for i in {1..50};
do
sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q "SELECT 1" &> /dev/null
if [ $? -eq 0 ]
then
echo "SQL Server is ready"
break
else
echo "SQL Server is not ready yet..."
sleep 1
fi
done
# Run the initialization script
echo "Running initialization script..."
sqlcmd -S localhost -U sa -P $SA_PASSWORD -i /usr/src/app/init.sql
if [ $? -ne 0 ]; then
echo "Error executing initialization script"
exit 1
fi
# Run all schema scripts in the schemas directory
echo "Running schema scripts..."
for f in /usr/src/app/schemas/*.sql
do
echo "Processing $f..."
sqlcmd -S localhost -U sa -P $SA_PASSWORD -i "$f" -b
if [ $? -ne 0 ]; then
echo "Error executing schema script $f"
exit 1
fi
# Verify schema creation
sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q "SELECT name FROM sys.schemas WHERE name IN ('fp', 'fw', 'int', 'ob')" -h -1
done
echo "All scripts executed. SQL Server is ready."
# Keep container running
while true; do
sleep 1
done