Adjust setup.sh file to work with inline go statements

This commit is contained in:
Ubuntu 2025-02-04 20:42:10 +00:00
parent 17fb400150
commit 50eae904e4
11 changed files with 40 additions and 9 deletions

View File

@ -1047,7 +1047,6 @@ CREATE TABLE [dbo].[ColumnStoreIndex] (
[i] int NOT NULL [i] int NOT NULL
); );
CREATE NONCLUSTERED COLUMNSTORE INDEX [nccx_ColumnStoreIndex] ON [dbo].[ColumnStoreIndex] () INCLUDE ([i]);
GO GO
--------------------------------------------- ---------------------------------------------
@ -12815,7 +12814,6 @@ CREATE TABLE [dbo].[WFHistory] (
PRIMARY KEY ([WorkflowHistoryGUID]) PRIMARY KEY ([WorkflowHistoryGUID])
); );
CREATE NONCLUSTERED COLUMNSTORE INDEX [NCCNU_WorkflowHistoryGUID] ON [dbo].[WFHistory] () INCLUDE ([WorkflowHistoryGUID]);
GO GO
ALTER TABLE [dbo].[WFHistory] ADD CONSTRAINT [FK_WFHistory_WFWorkflowMap] FOREIGN KEY ([WorkflowMapGUID]) REFERENCES [dbo].[WFWorkflowMap] ([WorkflowMapGUID]); GO ALTER TABLE [dbo].[WFHistory] ADD CONSTRAINT [FK_WFHistory_WFWorkflowMap] FOREIGN KEY ([WorkflowMapGUID]) REFERENCES [dbo].[WFWorkflowMap] ([WorkflowMapGUID]); GO
ALTER TABLE [dbo].[WFHistory] ADD CONSTRAINT [FK_WFHistory_WFWorkflowStep] FOREIGN KEY ([WorkflowStepGUID]) REFERENCES [dbo].[WFWorkflowStep] ([WorkflowStepGUID]); GO ALTER TABLE [dbo].[WFHistory] ADD CONSTRAINT [FK_WFHistory_WFWorkflowStep] FOREIGN KEY ([WorkflowStepGUID]) REFERENCES [dbo].[WFWorkflowStep] ([WorkflowStepGUID]); GO
@ -13526,7 +13524,7 @@ CREATE TABLE [dbo].[dtproperties] (
[property] varchar(64) NOT NULL, [property] varchar(64) NOT NULL,
[value] varchar(255) NULL, [value] varchar(255) NULL,
[uvalue] nvarchar(255) NULL, [uvalue] nvarchar(255) NULL,
[lvalue] image(2147483647) NULL, [lvalue] image NULL,
[version] int NOT NULL, [version] int NOT NULL,
PRIMARY KEY ([id], [property]) PRIMARY KEY ([id], [property])
); );

View File

@ -8,6 +8,9 @@
--------------------------------------------- ---------------------------------------------
-- dbo.AMAssumptionView ------------------ -- dbo.AMAssumptionView ------------------
--------------------------------------------- ---------------------------------------------
DROP TABLE [dbo].[AMAssumptionView];
GO
CREATE TABLE [dbo].[AMAssumptionView] ( CREATE TABLE [dbo].[AMAssumptionView] (
[AssumptionViewGUID] uniqueidentifier NOT NULL, [AssumptionViewGUID] uniqueidentifier NOT NULL,
[AssumptionGroupGUID] uniqueidentifier NOT NULL, [AssumptionGroupGUID] uniqueidentifier NOT NULL,
@ -36,3 +39,4 @@ ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_FOLDERG
ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_ISDISTRIBUTIONMODEACTIVE] DEFAULT ((0)) FOR [IsDistributionModeActive]; GO ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_ISDISTRIBUTIONMODEACTIVE] DEFAULT ((0)) FOR [IsDistributionModeActive]; GO
ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_DISTRIBUTIONINFOXML] DEFAULT ('') FOR [DistributionInfo]; GO ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_DISTRIBUTIONINFOXML] DEFAULT ('') FOR [DistributionInfo]; GO
ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_PROVIDERGUID] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [ProviderGUID]; GO ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_PROVIDERGUID] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [ProviderGUID]; GO

View File

@ -8,6 +8,9 @@
--------------------------------------------- ---------------------------------------------
-- fp.APAdminPerformanceTest ------------------ -- fp.APAdminPerformanceTest ------------------
--------------------------------------------- ---------------------------------------------
DROP TABLE [fp].[APAdminPerformanceTest];
GO
CREATE TABLE [fp].[APAdminPerformanceTest] ( CREATE TABLE [fp].[APAdminPerformanceTest] (
[TestID] uniqueidentifier NOT NULL, [TestID] uniqueidentifier NOT NULL,
[SortOrder] int NOT NULL, [SortOrder] int NOT NULL,

View File

@ -8,6 +8,9 @@
--------------------------------------------- ---------------------------------------------
-- fw.ABBBudgetedCostPerRVU ------------------ -- fw.ABBBudgetedCostPerRVU ------------------
--------------------------------------------- ---------------------------------------------
DROP TABLE [fw].[ABBBudgetedCostPerRVU];
GO
CREATE TABLE [fw].[ABBBudgetedCostPerRVU] ( CREATE TABLE [fw].[ABBBudgetedCostPerRVU] (
[DepartmentID] int NOT NULL, [DepartmentID] int NOT NULL,
[AccountID] int NOT NULL, [AccountID] int NOT NULL,

View File

@ -8,6 +8,9 @@
--------------------------------------------- ---------------------------------------------
-- int.AggregatePostDIHistory ------------------ -- int.AggregatePostDIHistory ------------------
--------------------------------------------- ---------------------------------------------
DROP TABLE [int].[AggregatePostDIHistory];
GO
CREATE TABLE [int].[AggregatePostDIHistory] ( CREATE TABLE [int].[AggregatePostDIHistory] (
[AggregatePostDIHistoryGuid] uniqueidentifier NOT NULL, [AggregatePostDIHistoryGuid] uniqueidentifier NOT NULL,
[CreatedAtUtc] datetime NOT NULL, [CreatedAtUtc] datetime NOT NULL,

View File

@ -8,6 +8,9 @@
--------------------------------------------- ---------------------------------------------
-- ob.AccountVariabilityOverride ------------------ -- ob.AccountVariabilityOverride ------------------
--------------------------------------------- ---------------------------------------------
DROP TABLE [ob].[AccountVariabilityOverride];
GO
CREATE TABLE [ob].[AccountVariabilityOverride] ( CREATE TABLE [ob].[AccountVariabilityOverride] (
[AccountVariabilityOverrideID] int NOT NULL, [AccountVariabilityOverrideID] int NOT NULL,
[DepartmentAssignment] nvarchar(800) NOT NULL, [DepartmentAssignment] nvarchar(800) NOT NULL,

View File

@ -21,9 +21,17 @@ do
fi fi
done done
# Create st-database if it doesn't exist
echo "Creating st-database if it doesn't exist..."
sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'st-database') CREATE DATABASE [st-database]"
if [ $? -ne 0 ]; then
echo "Error creating database"
exit 1
fi
# Run the initialization script # Run the initialization script
echo "Running initialization script..." echo "Running initialization script..."
sqlcmd -S localhost -U sa -P $SA_PASSWORD -i /usr/src/app/init.sql sqlcmd -S localhost -U sa -P $SA_PASSWORD -d st-database -i /usr/src/app/init.sql
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing initialization script" echo "Error executing initialization script"
exit 1 exit 1
@ -34,14 +42,23 @@ echo "Running schema scripts..."
for f in /usr/src/app/schemas/*.sql for f in /usr/src/app/schemas/*.sql
do do
echo "Processing $f..." echo "Processing $f..."
sqlcmd -S localhost -U sa -P $SA_PASSWORD -i "$f" -b
# Create a temporary file
temp_file=$(mktemp)
# Process the file: add newlines around GO statements
sed 's/GO/\nGO\n/g' "$f" > "$temp_file"
# Execute the processed file
sqlcmd -S localhost -U sa -P $SA_PASSWORD -d st-database -i "$temp_file"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing schema script $f" echo "Warning: Script $f had some errors but continuing..."
exit 1 rm "$temp_file" # Clean up temp file
continue
fi fi
# Verify schema creation # Clean up temp file
sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q "SELECT name FROM sys.schemas WHERE name IN ('fp', 'fw', 'int', 'ob')" -h -1 rm "$temp_file"
done done
echo "All scripts executed. SQL Server is ready." echo "All scripts executed. SQL Server is ready."