From 9b1609e256cc1dbf3eac5d447039081f2b260d03 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 5 Feb 2025 01:18:33 +0000 Subject: [PATCH] organize database scripts --- .../infrastructure/sql-server/Dockerfile | 17 +- .../{full_schemas => }/extract_constraints.sh | 3 + .../{full_schemas => }/extract_indexes.sh | 3 + .../{full_schemas => }/extract_procedures.sh | 3 + .../sql-server/extract_tables.sh | 150 ++++++++++++++++++ .../{full_schemas => }/extract_views.sh | 3 + .../sql-server/full_schemas/extract_tables.sh | 105 ------------ .../sql-server/full_schemas/parse_sql.sh | 116 -------------- .../infrastructure/sql-server/setup.sh | 80 +++++++--- .../dbo_schema_database_statements_small.sql | 42 ----- .../fp_schema_database_statements_small.sql | 43 ----- .../fw_schema_database_statements_small.sql | 25 --- .../int_schema_database_statements_small.sql | 25 --- .../ob_schema_database_statements_small.sql | 27 ---- 14 files changed, 236 insertions(+), 406 deletions(-) rename ef-migration/infrastructure/sql-server/{full_schemas => }/extract_constraints.sh (98%) rename ef-migration/infrastructure/sql-server/{full_schemas => }/extract_indexes.sh (99%) rename ef-migration/infrastructure/sql-server/{full_schemas => }/extract_procedures.sh (99%) create mode 100755 ef-migration/infrastructure/sql-server/extract_tables.sh rename ef-migration/infrastructure/sql-server/{full_schemas => }/extract_views.sh (98%) delete mode 100755 ef-migration/infrastructure/sql-server/full_schemas/extract_tables.sh delete mode 100755 ef-migration/infrastructure/sql-server/full_schemas/parse_sql.sh delete mode 100644 ef-migration/infrastructure/sql-server/small_schemas/dbo_schema_database_statements_small.sql delete mode 100644 ef-migration/infrastructure/sql-server/small_schemas/fp_schema_database_statements_small.sql delete mode 100644 ef-migration/infrastructure/sql-server/small_schemas/fw_schema_database_statements_small.sql delete mode 100644 ef-migration/infrastructure/sql-server/small_schemas/int_schema_database_statements_small.sql delete mode 100644 ef-migration/infrastructure/sql-server/small_schemas/ob_schema_database_statements_small.sql diff --git a/ef-migration/infrastructure/sql-server/Dockerfile b/ef-migration/infrastructure/sql-server/Dockerfile index af53d90..635ecc5 100644 --- a/ef-migration/infrastructure/sql-server/Dockerfile +++ b/ef-migration/infrastructure/sql-server/Dockerfile @@ -8,7 +8,7 @@ ENV ACCEPT_EULA=Y \ DROP_DATABASE=false \ PATH="/opt/mssql-tools/bin:${PATH}" -# Install sqlcmd utility +# Install sqlcmd utility and other required packages USER root RUN apt-get update && \ apt-get install -y wget software-properties-common gnupg2 && \ @@ -21,16 +21,23 @@ RUN apt-get update && \ # Create app directory and schemas subdirectory in one layer WORKDIR /usr/src/app -RUN mkdir -p schemas +RUN mkdir -p schemas && \ + mkdir -p sql_objects/{tables,constraints,foreign_keys,indexes/{clustered,nonclustered,unique_clustered},views,procedures} && \ + chown -R mssql:mssql /usr/src/app && \ + chmod -R 755 /usr/src/app -# Copy all SQL files in a single layer to reduce image size +# Copy all SQL files and scripts in a single layer to reduce image size COPY ./sql-server/schemas/*.sql ./schemas/ COPY ./sql-server/init.sql ./ COPY ./sql-server/setup.sh ./ +COPY ./sql-server/extract_*.sh ./ -# Fix line endings and make setup script executable +# Fix line endings and make all scripts executable RUN sed -i 's/\r$//' setup.sh && \ - chmod +x setup.sh + sed -i 's/\r$//' extract_*.sh && \ + chmod +x setup.sh && \ + chmod +x extract_*.sh && \ + chown -R mssql:mssql /usr/src/app # Switch back to mssql user USER mssql diff --git a/ef-migration/infrastructure/sql-server/full_schemas/extract_constraints.sh b/ef-migration/infrastructure/sql-server/extract_constraints.sh similarity index 98% rename from ef-migration/infrastructure/sql-server/full_schemas/extract_constraints.sh rename to ef-migration/infrastructure/sql-server/extract_constraints.sh index a4ce1d8..cfe2b2a 100755 --- a/ef-migration/infrastructure/sql-server/full_schemas/extract_constraints.sh +++ b/ef-migration/infrastructure/sql-server/extract_constraints.sh @@ -12,6 +12,9 @@ BASE_DIR="sql_objects" # Create directory structure mkdir -p "$BASE_DIR"/{constraints,foreign_keys} +# Ensure proper permissions +chmod -R 755 "$BASE_DIR" + # Function to clean filename clean_filename() { # Remove brackets, convert dots and spaces to underscores, remove parentheses diff --git a/ef-migration/infrastructure/sql-server/full_schemas/extract_indexes.sh b/ef-migration/infrastructure/sql-server/extract_indexes.sh similarity index 99% rename from ef-migration/infrastructure/sql-server/full_schemas/extract_indexes.sh rename to ef-migration/infrastructure/sql-server/extract_indexes.sh index 89037dc..df0aa95 100755 --- a/ef-migration/infrastructure/sql-server/full_schemas/extract_indexes.sh +++ b/ef-migration/infrastructure/sql-server/extract_indexes.sh @@ -14,6 +14,9 @@ mkdir -p "$BASE_DIR/indexes/clustered" mkdir -p "$BASE_DIR/indexes/nonclustered" mkdir -p "$BASE_DIR/indexes/unique_clustered" +# Ensure proper permissions +chmod -R 755 "$BASE_DIR" + # Function to clean filename clean_filename() { # Remove brackets, convert dots and spaces to underscores, remove parentheses diff --git a/ef-migration/infrastructure/sql-server/full_schemas/extract_procedures.sh b/ef-migration/infrastructure/sql-server/extract_procedures.sh similarity index 99% rename from ef-migration/infrastructure/sql-server/full_schemas/extract_procedures.sh rename to ef-migration/infrastructure/sql-server/extract_procedures.sh index 674bea6..62add30 100755 --- a/ef-migration/infrastructure/sql-server/full_schemas/extract_procedures.sh +++ b/ef-migration/infrastructure/sql-server/extract_procedures.sh @@ -12,6 +12,9 @@ BASE_DIR="sql_objects" # Create directory structure mkdir -p "$BASE_DIR/procedures" +# Ensure proper permissions +chmod -R 755 "$BASE_DIR" + # Function to clean filename clean_filename() { # Remove brackets, convert dots and spaces to underscores, remove parentheses diff --git a/ef-migration/infrastructure/sql-server/extract_tables.sh b/ef-migration/infrastructure/sql-server/extract_tables.sh new file mode 100755 index 0000000..5948bd4 --- /dev/null +++ b/ef-migration/infrastructure/sql-server/extract_tables.sh @@ -0,0 +1,150 @@ +#!/bin/bash + +# Check if input file is provided +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +SQL_FILE="$1" +BASE_DIR="/usr/src/app/sql_objects" # Use absolute path + +# Create directory structure with proper permissions +echo "Creating directory structure at $BASE_DIR/tables" +mkdir -p "$BASE_DIR/tables" +chmod -R 777 "$BASE_DIR" # Give full permissions for testing + +# Function to check if table is temporary +is_temporary_table() { + local table_name="$1" + if echo "$table_name" | grep -iE "^(#|tmp_|temp_|temporary_|import_|viewimport_)" >/dev/null; then + return 0 # true in bash + else + return 1 # false in bash + fi +} + +# Function to clean filename +clean_filename() { + # Remove brackets, convert dots and spaces to underscores, remove parentheses + echo "$1" | sed 's/\[\|\]//g' | tr '.' '_' | tr ' ' '_' | sed 's/[()]//g' | sed 's/__*/_/g' | sed 's/_$//' +} + +# Function to extract table name with better schema handling +extract_table_name() { + local create_statement="$1" + # First, try to match schema.table pattern with brackets + local table_name=$(echo "$create_statement" | sed -nE 's/.*CREATE[[:space:]]+TABLE[[:space:]]+\[([^]]+)\]\.\[([^]]+)\].*/\1.\2/p') + + if [ -z "$table_name" ]; then + # Try to match schema.table pattern without brackets + table_name=$(echo "$create_statement" | sed -nE 's/.*CREATE[[:space:]]+TABLE[[:space:]]+([^.[:space:]]+)\.([^.[:space:]]+).*/\1.\2/p') + fi + + if [ -z "$table_name" ]; then + # Try to match just table name with brackets + table_name=$(echo "$create_statement" | sed -nE 's/.*CREATE[[:space:]]+TABLE[[:space:]]+\[([^]]+)\].*/\1/p') + fi + + if [ -z "$table_name" ]; then + # Try to match just table name without brackets + table_name=$(echo "$create_statement" | sed -nE 's/.*CREATE[[:space:]]+TABLE[[:space:]]+([^[:space:]]+).*/\1/p') + fi + + echo "$table_name" +} + +# Function to process each CREATE TABLE statement +process_table() { + local table_statement="$1" + local table_name=$(extract_table_name "$table_statement") + + # Debug output + echo "Extracted table name: $table_name" + + # Skip if we couldn't extract table name + if [ -z "$table_name" ]; then + echo "Warning: Could not extract table name from statement:" + echo "$table_statement" | head -n 1 + return + fi + + # Check if it's a temporary table + if is_temporary_table "$table_name"; then + echo "Skipping temporary table: $table_name" + return + fi + + # Clean filename and create full path + clean_name=$(clean_filename "${table_name}") + output_file="$BASE_DIR/tables/${clean_name}.sql" + + echo "Attempting to write to: $output_file" + # Create the file with proper error handling + if ! echo "$table_statement" > "$output_file" 2>/dev/null; then + echo "Error writing to $output_file" + echo "Current permissions:" + ls -la "$BASE_DIR/tables" + return 1 + fi + + echo "Successfully created: $output_file" +} + +# Main processing function +extract_tables() { + local current_statement="" + local capture_table=false + + # Read the file line by line + while IFS= read -r line || [ -n "$line" ]; do + # Skip empty lines and pure comment lines + if [ -z "${line// }" ] || [[ "$line" =~ ^[[:space:]]*-- ]]; then + continue + fi + + # Check for CREATE TABLE statement + if echo "$line" | grep -i "CREATE[[:space:]]\+TABLE" > /dev/null; then + # Debug output + echo "Found CREATE TABLE statement: $line" + local table_name=$(extract_table_name "$line") + echo "Extracted table name from line: $table_name" + + if ! is_temporary_table "$table_name"; then + capture_table=true + current_statement="$line" + else + echo "Skipping temporary table: $table_name" + fi + continue + fi + + # If we're capturing a table + if $capture_table; then + current_statement+=$'\n'"$line" + + # If we find a GO statement, process the table + if echo "$line" | grep -i "^[[:space:]]*GO[[:space:]]*$" > /dev/null; then + process_table "$current_statement" + capture_table=false + current_statement="" + fi + fi + done < "$SQL_FILE" + + # Process any remaining table statement + if $capture_table && [ -n "$current_statement" ]; then + process_table "$current_statement" + fi +} + +# Remove comment lines and process +echo "Starting table extraction from $SQL_FILE to $BASE_DIR/tables" +echo "Current working directory: $(pwd)" +echo "Directory contents before extraction:" +ls -la "$BASE_DIR/tables" + +sed 's/--.*$//' "$SQL_FILE" | extract_tables + +echo "Extraction completed. Directory contents after extraction:" +ls -la "$BASE_DIR/tables" \ No newline at end of file diff --git a/ef-migration/infrastructure/sql-server/full_schemas/extract_views.sh b/ef-migration/infrastructure/sql-server/extract_views.sh similarity index 98% rename from ef-migration/infrastructure/sql-server/full_schemas/extract_views.sh rename to ef-migration/infrastructure/sql-server/extract_views.sh index a708894..a138fac 100755 --- a/ef-migration/infrastructure/sql-server/full_schemas/extract_views.sh +++ b/ef-migration/infrastructure/sql-server/extract_views.sh @@ -12,6 +12,9 @@ BASE_DIR="sql_objects" # Create directory structure mkdir -p "$BASE_DIR/views" +# Ensure proper permissions +chmod -R 755 "$BASE_DIR" + # Function to clean filename clean_filename() { # Remove brackets, convert dots and spaces to underscores, remove parentheses diff --git a/ef-migration/infrastructure/sql-server/full_schemas/extract_tables.sh b/ef-migration/infrastructure/sql-server/full_schemas/extract_tables.sh deleted file mode 100755 index d9959d2..0000000 --- a/ef-migration/infrastructure/sql-server/full_schemas/extract_tables.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -# Check if input file is provided -if [ $# -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -SQL_FILE="$1" -BASE_DIR="sql_objects" - -# Create directory structure -mkdir -p "$BASE_DIR/tables" - -# Function to clean filename -clean_filename() { - # Remove brackets, convert dots and spaces to underscores, remove parentheses - echo "$1" | sed 's/\[\|\]//g' | tr '.' '_' | tr ' ' '_' | sed 's/[()]//g' | sed 's/__*/_/g' | sed 's/_$//' -} - -# Function to check if table is temporary -is_temporary_table() { - local table_name="$1" - if echo "$table_name" | grep -iE "temp|tmp|temporary|import_|viewimport_" >/dev/null; then - return 0 # true in bash - else - return 1 # false in bash - fi -} - -# Function to extract CREATE TABLE statements only -extract_tables() { - local current_object="" - local capture_table=false - local table_name="" - - # Read the file line by line - while IFS= read -r line || [ -n "$line" ]; do - # Check if we've found a CREATE TABLE statement - if echo "$line" | grep -i "CREATE[[:space:]]\+TABLE" >/dev/null; then - # Extract table name and check if it's temporary - table_name=$(echo "$line" | sed -E 's/.*CREATE[[:space:]]+TABLE[[:space:]]+\[?([^\]]+)\]?.*/\1/') - - if is_temporary_table "$table_name"; then - echo "Skipping temporary table: $table_name" - continue - fi - - capture_table=true - current_object="$line"$'\n' - continue - fi - - # If we're capturing a table and find a following CREATE or ALTER statement, stop capturing - if $capture_table; then - if echo "$line" | grep -i "^[[:space:]]*CREATE\|^[[:space:]]*ALTER" >/dev/null; then - # Save the current table before starting a new object - if [ -n "$table_name" ]; then - clean_name=$(clean_filename "$table_name") - output_file="$BASE_DIR/tables/${clean_name}.sql" - echo "$current_object" > "$output_file" - echo "Created: $output_file" - fi - capture_table=false - current_object="" - table_name="" - continue - fi - - # Add line to current object if we're still capturing - current_object+="$line"$'\n' - - # If we find a GO statement, save the table - if echo "$line" | grep -i "^[[:space:]]*GO[[:space:]]*$" >/dev/null; then - if [ -n "$table_name" ]; then - clean_name=$(clean_filename "$table_name") - output_file="$BASE_DIR/tables/${clean_name}.sql" - echo "$current_object" > "$output_file" - echo "Created: $output_file" - fi - capture_table=false - current_object="" - table_name="" - fi - fi - done < "$SQL_FILE" -} - -# Remove comment lines starting with -- -echo "Extracting CREATE TABLE statements..." -sed 's/--.*$//' "$SQL_FILE" | extract_tables - -echo "CREATE TABLE statements have been saved in $BASE_DIR/tables/" - -# Count files -count=$(ls -1 "$BASE_DIR/tables"/*.sql 2>/dev/null | wc -l) -echo -e "\nTotal tables extracted: $count" - -# List extracted tables -echo -e "\nExtracted tables:" -for table in "$BASE_DIR/tables"/*.sql; do - if [ -f "$table" ]; then - echo "- $(basename "$table")" - fi -done \ No newline at end of file diff --git a/ef-migration/infrastructure/sql-server/full_schemas/parse_sql.sh b/ef-migration/infrastructure/sql-server/full_schemas/parse_sql.sh deleted file mode 100755 index afa86a4..0000000 --- a/ef-migration/infrastructure/sql-server/full_schemas/parse_sql.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash - -# Check if input file is provided -if [ $# -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -SQL_FILE="$1" -BASE_DIR="sql_objects" - -# Create directory structure -mkdir -p "$BASE_DIR"/{tables,views,procedures,constraints,indexes,alter_tables} - -# Function to clean filename -clean_filename() { - echo "$1" | sed 's/\[\|\]//g' | tr '.' '_' -} - -# Function to extract SQL objects and save to files -extract_objects() { - local current_object="" - local object_type="" - local object_name="" - local table_name="" - - # Read the file line by line - while IFS= read -r line || [ -n "$line" ]; do - # Skip empty lines at the start - if [ -z "$current_object" ] && [ -z "${line// }" ]; then - continue - fi - - # Add line to current object - current_object+="$line"$'\n' - - # Check if we've reached the end of an object (GO statement) - if echo "$line" | grep -i "^[[:space:]]*GO[[:space:]]*$" >/dev/null; then - # Determine object type and name - if echo "$current_object" | grep -i "CREATE[[:space:]]\+TABLE" >/dev/null; then - object_type="tables" - object_name=$(echo "$current_object" | grep -i "CREATE[[:space:]]\+TABLE" | sed -E 's/.*CREATE[[:space:]]+TABLE[[:space:]]+\[?([^\]]+)\]?.*/\1/') - elif echo "$current_object" | grep -i "CREATE[[:space:]]\+VIEW" >/dev/null; then - object_type="views" - object_name=$(echo "$current_object" | grep -i "CREATE[[:space:]]\+VIEW" | sed -E 's/.*CREATE[[:space:]]+VIEW[[:space:]]+\[?([^\]]+)\]?.*/\1/') - elif echo "$current_object" | grep -i "CREATE[[:space:]]\+PROC" >/dev/null; then - object_type="procedures" - object_name=$(echo "$current_object" | grep -i "CREATE[[:space:]]\+PROC[[:space:]EDURE]*" | sed -E 's/.*CREATE[[:space:]]+PROC[[:space:]EDURE]*[[:space:]]+\[?([^\]]+)\]?.*/\1/') - elif echo "$current_object" | grep -i "ALTER[[:space:]]\+TABLE" >/dev/null; then - # Extract table name and constraint name if it exists - table_name=$(echo "$current_object" | grep -i "ALTER[[:space:]]\+TABLE" | sed -E 's/.*ALTER[[:space:]]+TABLE[[:space:]]+\[?([^\]]+)\]?.*/\1/') - - if echo "$current_object" | grep -i "ADD[[:space:]]\+CONSTRAINT" >/dev/null; then - object_type="constraints" - object_name=$(echo "$current_object" | grep -i "CONSTRAINT" | sed -E 's/.*CONSTRAINT[[:space:]]+\[?([^\]]+)\]?.*/\1/') - else - object_type="alter_tables" - object_name="${table_name}_alter_$(date +%s%N | cut -b1-5)" - fi - elif echo "$current_object" | grep -i "CREATE.*INDEX" >/dev/null; then - object_type="indexes" - object_name=$(echo "$current_object" | grep -i "INDEX" | sed -E 's/.*INDEX[[:space:]]+\[?([^\]]+)\]?.*/\1/') - fi - - # If we identified an object type and name, save it - if [ -n "$object_type" ] && [ -n "$object_name" ]; then - # Clean the filename - clean_name=$(clean_filename "$object_name") - output_file="$BASE_DIR/$object_type/$clean_name.sql" - - # For alter_tables, make sure we don't overwrite existing files - if [ "$object_type" = "alter_tables" ]; then - counter=1 - base_file="$BASE_DIR/$object_type/$clean_name" - while [ -f "${base_file}.sql" ]; do - clean_name="${clean_name}_${counter}" - counter=$((counter + 1)) - done - output_file="$base_file.sql" - fi - - # Save the object to file - echo "$current_object" > "$output_file" - echo "Created: $output_file" - fi - - # Reset for next object - current_object="" - object_type="" - object_name="" - table_name="" - fi - done < "$SQL_FILE" -} - -# Remove comment lines starting with -- -echo "Removing comments and processing SQL file..." -sed 's/--.*$//' "$SQL_FILE" | extract_objects - -echo "SQL objects have been organized in the $BASE_DIR directory." -echo " -Directory structure: -$BASE_DIR/ -├── tables/ -├── views/ -├── procedures/ -├── constraints/ -├── indexes/ -└── alter_tables/" - -# Count files in each directory -echo -e "\nFile counts:" -for dir in tables views procedures constraints indexes alter_tables; do - count=$(ls -1 "$BASE_DIR/$dir"/*.sql 2>/dev/null | wc -l) - echo "$dir: $count files" -done \ No newline at end of file diff --git a/ef-migration/infrastructure/sql-server/setup.sh b/ef-migration/infrastructure/sql-server/setup.sh index 3730046..6e0245c 100644 --- a/ef-migration/infrastructure/sql-server/setup.sh +++ b/ef-migration/infrastructure/sql-server/setup.sh @@ -76,31 +76,75 @@ else exit 1 fi - # Run all schema scripts in the schemas directory - echo "Running schema scripts..." - for f in /usr/src/app/schemas/*.sql + # Clean up existing files in sql_objects directories + echo "Cleaning up existing files..." + rm -f /usr/src/app/sql_objects/*/*.sql + rm -f /usr/src/app/sql_objects/indexes/*/*.sql + + # Process each schema file through the extraction scripts + echo "Processing schema files..." + for schema_file in /usr/src/app/schemas/*.sql do - echo "Processing $f..." + echo "Processing schema file: $schema_file" - # 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" + # Extract different types of SQL objects + bash /usr/src/app/extract_tables.sh "$schema_file" if [ $? -ne 0 ]; then - echo "Warning: Script $f had some errors but continuing..." - rm "$temp_file" # Clean up temp file - continue + echo "Warning: Table extraction had some errors but continuing..." fi - # Clean up temp file - rm "$temp_file" + bash /usr/src/app/extract_constraints.sh "$schema_file" + bash /usr/src/app/extract_indexes.sh "$schema_file" + bash /usr/src/app/extract_views.sh "$schema_file" + bash /usr/src/app/extract_procedures.sh "$schema_file" done - echo "All scripts executed. SQL Server is ready." + # Function to execute SQL files from a directory + execute_sql_files() { + local dir=$1 + local type=$2 + + if [ -d "$dir" ] && [ "$(ls -A $dir 2>/dev/null)" ]; then + echo "Executing $type..." + for sql_file in "$dir"/*.sql; do + if [ -f "$sql_file" ]; then + echo "Executing $sql_file..." + sqlcmd -S localhost -U sa -P $SA_PASSWORD -d st-database -i "$sql_file" + if [ $? -ne 0 ]; then + echo "Warning: Error executing $sql_file but continuing..." + fi + fi + done + else + echo "No files found in $dir" + fi + } + + # Execute SQL objects in the correct order + echo "Executing SQL objects in order..." + + # 1. Tables + execute_sql_files "sql_objects/tables" "tables" + + # 2. Constraints + execute_sql_files "sql_objects/constraints" "constraints" + execute_sql_files "sql_objects/foreign_keys" "foreign keys" + + # 3. Indexes + execute_sql_files "sql_objects/indexes/clustered" "clustered indexes" + execute_sql_files "sql_objects/indexes/unique_clustered" "unique clustered indexes" + execute_sql_files "sql_objects/indexes/nonclustered" "nonclustered indexes" + + # 4. Views + execute_sql_files "sql_objects/views" "views" + + # 5. Stored Procedures + execute_sql_files "sql_objects/procedures" "stored procedures" + + # Clean up + echo "Cleaning up..." + rm -rf sql_objects + echo "SQL object execution completed" fi # Keep container running diff --git a/ef-migration/infrastructure/sql-server/small_schemas/dbo_schema_database_statements_small.sql b/ef-migration/infrastructure/sql-server/small_schemas/dbo_schema_database_statements_small.sql deleted file mode 100644 index 7b675a2..0000000 --- a/ef-migration/infrastructure/sql-server/small_schemas/dbo_schema_database_statements_small.sql +++ /dev/null @@ -1,42 +0,0 @@ --- SCHEMA: dbo - ---------------------------------------------- --- TABLES ---------------------------------------------- - - ---------------------------------------------- --- dbo.AMAssumptionView ------------------ ---------------------------------------------- -DROP TABLE [dbo].[AMAssumptionView]; -GO - -CREATE TABLE [dbo].[AMAssumptionView] ( - [AssumptionViewGUID] uniqueidentifier NOT NULL, - [AssumptionGroupGUID] uniqueidentifier NOT NULL, - [Name] nvarchar(450) NOT NULL, - [ColumnWidths] varchar(8000) NOT NULL, - [AssumptionJoinDataGUID] uniqueidentifier NOT NULL, - [FolderGUID] uniqueidentifier NOT NULL, - [IsDistributionModeActive] bit NOT NULL, - [DistributionInfo] xml NOT NULL, - [ProviderGUID] uniqueidentifier NOT NULL, - [CreatedDate] datetime NOT NULL, - [CreatedBy] uniqueidentifier NOT NULL, - [LastUsedDate] datetime NOT NULL, - PRIMARY KEY ([AssumptionViewGUID]) -); -GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_CreatedBy] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [CreatedBy]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_LastUsedDate] DEFAULT (getdate()) FOR [LastUsedDate]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_Table_1_AssumptionViewGUID] DEFAULT (newid()) FOR [AssumptionViewGUID]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_ASSUMPTIONGROUPGUID] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [AssumptionGroupGUID]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_NAME] DEFAULT ('') FOR [Name]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_COLUMNWIDTHS] DEFAULT ('') FOR [ColumnWidths]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_ASSUMPTIONCUBEGUID] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [AssumptionJoinDataGUID]; GO -ALTER TABLE [dbo].[AMAssumptionView] ADD CONSTRAINT [DF_AMAssumptionView_FOLDERGUID] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [FolderGUID]; 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_PROVIDERGUID] DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [ProviderGUID]; GO - diff --git a/ef-migration/infrastructure/sql-server/small_schemas/fp_schema_database_statements_small.sql b/ef-migration/infrastructure/sql-server/small_schemas/fp_schema_database_statements_small.sql deleted file mode 100644 index 31b867b..0000000 --- a/ef-migration/infrastructure/sql-server/small_schemas/fp_schema_database_statements_small.sql +++ /dev/null @@ -1,43 +0,0 @@ --- SCHEMA: fp - ---------------------------------------------- --- TABLES ---------------------------------------------- - - ---------------------------------------------- --- fp.APAdminPerformanceTest ------------------ ---------------------------------------------- -DROP TABLE [fp].[APAdminPerformanceTest]; -GO - -CREATE TABLE [fp].[APAdminPerformanceTest] ( - [TestID] uniqueidentifier NOT NULL, - [SortOrder] int NOT NULL, - [TestTypeID] tinyint NOT NULL, - [TestName] nvarchar(100) NOT NULL, - [Description] nvarchar(3000) NOT NULL, - [BudgetConfigID] int NOT NULL, - [SourceDimensionalityJSON] nvarchar(max) NOT NULL, - [TestDetailJSON] nvarchar(max) NOT NULL, - [IsActive] bit NOT NULL, - [CreatedBy] nvarchar(1000) NOT NULL, - [Target] int NOT NULL, - [MaximumTheshold] int NOT NULL, - [PickableDepartments] nvarchar(max) NOT NULL, - PRIMARY KEY ([TestID]) -); -GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Targe__5375AD4D] DEFAULT ((0)) FOR [Target]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Maxim__5469D186] DEFAULT ((0)) FOR [MaximumTheshold]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Picka__565219F8] DEFAULT ('') FOR [PickableDepartments]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__TestI__6B4249E6] DEFAULT (newid()) FOR [TestID]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__SortO__6C366E1F] DEFAULT ((0)) FOR [SortOrder]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__TestT__6D2A9258] DEFAULT ((0)) FOR [TestTypeID]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__TestN__6E1EB691] DEFAULT ('') FOR [TestName]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Descr__6F12DACA] DEFAULT ('') FOR [Description]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Budge__70FB233C] DEFAULT ((0)) FOR [BudgetConfigID]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Sourc__71EF4775] DEFAULT ('') FOR [SourceDimensionalityJSON]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__TestD__72E36BAE] DEFAULT ('') FOR [TestDetailJSON]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__IsAct__73D78FE7] DEFAULT ((0)) FOR [IsActive]; GO -ALTER TABLE [fp].[APAdminPerformanceTest] ADD CONSTRAINT [DF__APAdminPe__Creat__74CBB420] DEFAULT ('') FOR [CreatedBy]; GO diff --git a/ef-migration/infrastructure/sql-server/small_schemas/fw_schema_database_statements_small.sql b/ef-migration/infrastructure/sql-server/small_schemas/fw_schema_database_statements_small.sql deleted file mode 100644 index 510088c..0000000 --- a/ef-migration/infrastructure/sql-server/small_schemas/fw_schema_database_statements_small.sql +++ /dev/null @@ -1,25 +0,0 @@ --- SCHEMA: fw - ---------------------------------------------- --- TABLES ---------------------------------------------- - - ---------------------------------------------- --- fw.ABBBudgetedCostPerRVU ------------------ ---------------------------------------------- -DROP TABLE [fw].[ABBBudgetedCostPerRVU]; -GO - -CREATE TABLE [fw].[ABBBudgetedCostPerRVU] ( - [DepartmentID] int NOT NULL, - [AccountID] int NOT NULL, - [JobCodeID] int NOT NULL, - [PayCodeID] int NOT NULL, - [CostComponentID] int NOT NULL, - [CostingConfigGuid] uniqueidentifier NOT NULL, - [VariableDirectUnitCostPerRVU] decimal NULL, - [TotalVariableDirectCost] decimal NULL, - [TotalCost] decimal NULL -); -GO diff --git a/ef-migration/infrastructure/sql-server/small_schemas/int_schema_database_statements_small.sql b/ef-migration/infrastructure/sql-server/small_schemas/int_schema_database_statements_small.sql deleted file mode 100644 index 6ce75ad..0000000 --- a/ef-migration/infrastructure/sql-server/small_schemas/int_schema_database_statements_small.sql +++ /dev/null @@ -1,25 +0,0 @@ --- SCHEMA: int - ---------------------------------------------- --- TABLES ---------------------------------------------- - - ---------------------------------------------- --- int.AggregatePostDIHistory ------------------ ---------------------------------------------- -DROP TABLE [int].[AggregatePostDIHistory]; -GO - -CREATE TABLE [int].[AggregatePostDIHistory] ( - [AggregatePostDIHistoryGuid] uniqueidentifier NOT NULL, - [CreatedAtUtc] datetime NOT NULL, - [LastRanUtc] datetime NOT NULL, - [AggregatePostDIStatus] int NOT NULL, - PRIMARY KEY ([AggregatePostDIHistoryGuid]) -); -GO -ALTER TABLE [int].[AggregatePostDIHistory] ADD CONSTRAINT [DF__Aggregate__Aggre__4EDF0E15] DEFAULT (newid()) FOR [AggregatePostDIHistoryGuid]; GO -ALTER TABLE [int].[AggregatePostDIHistory] ADD CONSTRAINT [DF__Aggregate__Creat__4FD3324E] DEFAULT (getutcdate()) FOR [CreatedAtUtc]; GO -ALTER TABLE [int].[AggregatePostDIHistory] ADD CONSTRAINT [DF__Aggregate__LastR__50C75687] DEFAULT ('1900-01-01 00:00:00.000') FOR [LastRanUtc]; GO -ALTER TABLE [int].[AggregatePostDIHistory] ADD CONSTRAINT [DF__Aggregate__Aggre__51BB7AC0] DEFAULT ((0)) FOR [AggregatePostDIStatus]; GO diff --git a/ef-migration/infrastructure/sql-server/small_schemas/ob_schema_database_statements_small.sql b/ef-migration/infrastructure/sql-server/small_schemas/ob_schema_database_statements_small.sql deleted file mode 100644 index 43c249c..0000000 --- a/ef-migration/infrastructure/sql-server/small_schemas/ob_schema_database_statements_small.sql +++ /dev/null @@ -1,27 +0,0 @@ --- SCHEMA: ob - ---------------------------------------------- --- TABLES ---------------------------------------------- - - ---------------------------------------------- --- ob.AccountVariabilityOverride ------------------ ---------------------------------------------- -DROP TABLE [ob].[AccountVariabilityOverride]; -GO - -CREATE TABLE [ob].[AccountVariabilityOverride] ( - [AccountVariabilityOverrideID] int NOT NULL, - [DepartmentAssignment] nvarchar(800) NOT NULL, - [AccountAssignment] nvarchar(800) NOT NULL, - [PrecedentOrder] int NOT NULL, - [Variability] decimal NOT NULL, - PRIMARY KEY ([AccountVariabilityOverrideID]) -); -GO -ALTER TABLE [ob].[AccountVariabilityOverride] ADD CONSTRAINT [DF__AccountVa__Depar__0EB4746A] DEFAULT ('') FOR [DepartmentAssignment]; GO -ALTER TABLE [ob].[AccountVariabilityOverride] ADD CONSTRAINT [DF__AccountVa__Accou__0FA898A3] DEFAULT ('') FOR [AccountAssignment]; GO -ALTER TABLE [ob].[AccountVariabilityOverride] ADD CONSTRAINT [DF__AccountVa__Prece__109CBCDC] DEFAULT ((0)) FOR [PrecedentOrder]; GO -ALTER TABLE [ob].[AccountVariabilityOverride] ADD CONSTRAINT [DF__AccountVa__Varia__1190E115] DEFAULT ((0)) FOR [Variability]; GO -