SQL Server Documents

 https://drive.google.com/drive/folders/19oDBY0hyL35u5PtdbpuVrABCDzzo-zVK?usp=sharing

3 comments:


  1. ##verify inputs
    ##is first input valid flyway cmd
    #flag='n'
    case $flyway_type in
    migrate)
    ;;
    baseline)
    ;;
    repair)
    ;;
    validate)
    ;;
    info)
    ;;
    *)
    echo "Invalid flyway cmd parameter. Must be: migrate,baseline,repair,validate,info"
    exit
    esac


    ##verify environment exists
    flag='n'
    while read env schema
    do
    if [ "$env" == "$flyway_env" ]
    then
    flag='y'
    fi
    done < $flyway_dir/etms/globals.txt
    if [[ $flag = "n" ]];
    then
    echo "Invalid environment parameter. Must exist in $flyway_dir/etms/globals.txt"
    exit
    fi

    ##verify release exists
    getdir=$flyway_svn/$flyway_release
    if [ -d "$getdir" ]
    then
    break
    else
    echo "Invalid release parameter. Must be in $flyway_svn/$flyway_release directory"
    exit
    fi

    ## here we go
    #### get component information from the sql directory
    schemafile=$flyway_dir/schemafile.txt
    ls $flyway_svn/$3 |grep -v $schemafile |cut -c1-2|uniq > $schemafile

    case $flyway_type in
    migrate)
    mkdir $flyway_dir/etms/logs/$3
    rpt_file=$flyway_dir/etms/logs/$3/$2$dt'_migrate'.rpt
    ## write header to rpt file
    echo '********************' > $rpt_file
    echo 'environment = ' $2 >> $rpt_file
    echo 'release level = ' $3 >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    while read env schema
    do
    if [ "$env" == "$flyway_env" ]
    then
    while read component
    do
    if [ "$schema" == "$component" ]
    then
    out_file=$flyway_dir/etms/logs/$2$schema$3.out
    info_file=$flyway_dir/etms/logs/$3/$2$schema$dt'_migrate'.info
    ## writing more header info
    echo '********************' >> $rpt_file
    echo 'starting migration for '$env $schema >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    ## build flyway cmds
    $flyway_dir/flyway -table=$env$schema$3 -sqlMigrationPrefix=$schema -locations=filesystem:$flyway_svn/$flyway_release -configFile=$flyway_dir/conf/$env$schema.conf migrate > $out_file 2>&1
    $flyway_dir/flyway -table=$env$schema$3 -sqlMigrationPrefix=$schema -locations=filesystem:$flyway_svn/$flyway_release -configFile=$flyway_dir/conf/$env$schema.conf info > $info_file
    ## strip header off of files
    sed -i '1,3d' $info_file
    sed -i '1,3d' $out_file
    ## put files together
    cat $info_file >> $rpt_file
    cat $out_file >> $rpt_file
    echo ' ' >> $rpt_file
    fi
    done < $schemafile
    fi
    done < $flyway_dir/etms/globals.txt
    end=`date +%s`
    runtime=$((end-start))
    echo '' >> $rpt_file
    echo '********************' >> $rpt_file
    echo 'migration took ' $runtime ' seconds to complete ' >> $rpt_file
    echo '********************' >> $rpt_file
    ##mail results
    mail -s "flyway -- migration results for $flyway_env release $flyway_release" -r etms-dba@verizon.com $mail_to < $rpt_file
    break ;;
    baseline)
    mkdir $flyway_dir/etms/logs/$3
    rpt_file=$flyway_dir/etms/logs/$3/$2$dt'_baseline'.rpt
    ## write header to rpt file
    echo '********************' > $rpt_file
    echo 'environment = ' $2 >> $rpt_file
    echo 'release level = ' $3 >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file

    ReplyDelete
  2. while read env schema
    do
    if [ "$env" == "$flyway_env" ]
    then
    info_file=$flyway_dir/etms/logs/$3/$2$schema$dt'_baseline'.info
    ## writing more header info
    echo '********************' >> $rpt_file
    echo 'starting baseline for' $env $schema >> $rpt_file
    echo '********************' >> $rpt_file
    ## build flyway cmds
    flyway -configFile=$flyway_dir/conf/$env$schema.conf -table=$env$schema$3 baseline > $info_file 2>&1
    ## strip headers off file
    sed -i '1,3d' $info_file
    ## append to file
    cat $info_file >> $rpt_file
    echo ' ' >> $rpt_file
    fi
    done < ./etms/globals.txt
    end=`date +%s`
    runtime=$((end-start))
    echo '' >> $rpt_file
    echo '********************' >> $rpt_file
    echo 'baseline took ' $runtime ' seconds to complete ' >> $rpt_file
    echo '********************' >> $rpt_file
    mail -s "flyway -- baseline for $flyway_env release $flyway_release" $mail_to < $rpt_file
    break ;;
    repair)
    rpt_file=$flyway_dir/etms/logs/$3/$2$dt'_repair'.rpt
    ## write header to rpt file
    echo '********************' > $rpt_file
    echo 'environment = ' $2 >> $rpt_file
    echo 'release level = ' $3 >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    while read env schema
    do
    if [ "$env" == "$flyway_env" ]
    then
    while read component
    do
    if [ "$schema" == "$component" ]
    then
    info_file=$flyway_dir/etms/logs/$3/$2$schema$dt'_repair'.info
    ## writing more header info
    echo '********************' >> $rpt_file
    echo 'starting repair for' $env $schema >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    ## build flyway cmds
    flyway -configFile=$flyway_dir/conf/$env$schema.conf -table=$env$schema$3 repair > $info_file
    ## strip headers off file
    sed -i '1,3d' $info_file
    ## append file
    cat $info_file >> $rpt_file
    echo ' ' >> $rpt_file
    fi
    done < $schemafile
    fi
    done < ./etms/globals.txt
    end=`date +%s`
    runtime=$((end-start))
    echo '' >> $rpt_file
    echo '********************' >> $rpt_file
    echo 'repair took ' $runtime ' seconds to complete ' >> $rpt_file
    echo '********************' >> $rpt_file
    mail -s "flyway -- repair for $flyway_env release $flyway_release" -r etms-dba@v erizon.com $mail_to < $rpt_file
    break ;;

    ReplyDelete
  3. info)
    rpt_file=$flyway_dir/etms/logs/$3/$2$dt'_info'.rpt
    ## write header to rpt file
    echo '********************' > $rpt_file
    echo 'environment = ' $2 >> $rpt_file
    echo 'release level = ' $3 >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    while read env schema
    do
    if [ "$env" == "$flyway_env" ]
    then
    while read component
    do
    if [ "$schema" == "$component" ]
    then
    info_file=$flyway_dir/etms/logs/$3/$2$schema$dt'_info'.info
    ## writing more header info
    echo '********************' >> $rpt_file
    echo 'starting info for' $env $schema >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    ## build flyway cmds
    flyway -table=$env$schema$3 -sqlMigrationPrefix=$schema -locations=filesystem:$flyway_svn/$3 -configFile=$flyway_dir/conf/$env$schema.conf info > $info_file
    ## strip headers off file
    sed -i '1,3d' $info_file
    ## append file
    cat $info_file >> $rpt_file
    echo ' ' >> $rpt_file
    fi
    done < $schemafile
    fi
    done < ./etms/globals.txt
    end=`date +%s`
    runtime=$((end-start))
    echo '' >> $rpt_file
    echo '********************' >> $rpt_file
    echo 'info took ' $runtime ' seconds to complete ' >> $rpt_file
    echo '********************' >> $rpt_file
    mail -s "flyway -- info for $flyway_env release $flyway_release" $mail_to < $rpt_file
    break ;;
    validate)
    rpt_file=$flyway_dir/etms/logs/$3/$2$dt'_validate'.rpt
    ## write header to rpt file
    echo '********************' > $rpt_file
    echo 'environment = ' $2 >> $rpt_file
    echo 'release level = ' $3 >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    while read env schema
    do
    if [ "$env" == "$flyway_env" ]
    then
    while read component
    do
    if [ "$schema" == "$component" ]
    then
    info_file=$flyway_dir/etms/logs/$3/$2$schema$dt'_validate'.info
    ## writing more header info
    echo '********************' >> $rpt_file
    echo 'starting validate for' $env $schema >> $rpt_file
    echo '********************' >> $rpt_file
    echo ' ' >> $rpt_file
    ## build flyway cmds
    flyway -table=$env$schema$3 -sqlMigrationPrefix=$schema -locations=filesystem:$flyway_svn/$3 -configFile=$flyway_dir/conf/$env$schema.conf validate > $info_file 2>&1
    ## strip headers off file
    sed -i '1,3d' $info_file
    ## append file
    cat $info_file >> $rpt_file
    echo ' ' >> $rpt_file
    fi
    done < $schemafile
    fi
    done < ./etms/globals.txt
    end=`date +%s`
    runtime=$((end-start))
    echo '' >> $rpt_file
    echo '********************' >> $rpt_file
    echo 'validate took ' $runtime ' seconds to complete ' >> $rpt_file
    echo '********************' >> $rpt_file
    mail -s "flyway -- validate for $flyway_env release $flyway_release" $mail_to < $rpt_file
    break ;;
    esac
    #### clean up files
    rm $flyway_dir/etms/logs/*.out
    rm $flyway_dir/etms/logs/$3/*.info
    rm $flyway_dir/schemafile.txt

    ReplyDelete