Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* @credfeto
* @funfair-tech/Server
db/* @funfair-tech/ServerDatabase
Tools/* @funfair-tech/ServerDatabase
Tools/* @funfair-tech/ServerDatabase
1 change: 0 additions & 1 deletion .github/linters/.sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,3 @@ forbid_subquery_in = join
[sqlfluff:rules:convention.not_equal]
# Default to preferring the "ansi" (i.e. `<>`)
preferred_not_equal_style = ansi

2 changes: 1 addition & 1 deletion .github/linters/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@
"component-class-suffix": true,
"directive-class-suffix": true
}
}
}
1 change: 0 additions & 1 deletion .sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,3 @@ forbid_subquery_in = join
[sqlfluff:rules:convention.not_equal]
# Default to preferring the "ansi" (i.e. `<>`)
preferred_not_equal_style = ansi

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release
- Replace raw echo with output helpers in development/sln-migrate
- Replace raw echo with output helpers in development/restore-all
- Replace raw echo with output helpers in development/buildtest
- Replace raw echo with output helpers in development/buildnugetconfig
### Changed
- Replace raw echo with standard output helpers (die/info/success) in github/cancel-workflows
- Replace raw echo with standard output helpers (die/info/success) in git/update-repos-personal
Expand Down
4 changes: 2 additions & 2 deletions Colours.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SQL #413cd1
Tech Debt #30027a
Config Change #d8bb50
Unit-Tests #0e8a16
#Production Code Assemblies #96f7d2
#Production Code Assemblies #96f7d2
#Test Code Assemblies #0e8a16
auto-pr #0000aa
Migration Script #b680e5
Expand All @@ -23,4 +23,4 @@ github-actions #e09cf4
dependencies #0366d6
dotnet #db6baa
npm #e99695
DO NOT MERGE #ff0000
DO NOT MERGE #ff0000
1 change: 0 additions & 1 deletion db/create-deploy-script
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ sqlcompare \
/out:"$LOG" \
/empty2 \
/assertidentical

13 changes: 4 additions & 9 deletions db/createmssqldb
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
#!/bin/sh

die() {
echo
echo "$@"
exit 1
}

BASEDIR="$(dirname "$(readlink -f "$0")")"
echo "Script Dir: $BASEDIR"

SERVER=
DB=
USER=
PASSWORD=
SCHEMA=

# Not following:
# Not following:
# shellcheck disable=1091
. "$BASEDIR/dbenv"
. "$BASEDIR/dbenv"

info "Script Dir: $BASEDIR"

while [ $# -gt 0 ]; do
key="$1"
Expand Down
69 changes: 45 additions & 24 deletions db/dbenv
Original file line number Diff line number Diff line change
@@ -1,36 +1,58 @@
#!/bin/sh

CURRENT_DIR=$PWD
echo "Current Dir: $CURRENT_DIR"

die() {
echo
echo "$@"
if [ -t 2 ]; then
printf '\n\033[31m✗\033[0m %s\n' "$*" >&2
else
printf '\n✗ %s\n' "$*" >&2
fi
exit 1
}

success() {
if [ -t 1 ]; then
printf '\n\033[32m✓\033[0m %s\n' "$*"
else
printf '\n✓ %s\n' "$*"
fi
}

info() {
if [ -t 1 ]; then
printf '\n\033[32m→\033[0m %s\n' "$*"
else
printf '\n→ %s\n' "$*"
fi
}

CURRENT_DIR=$PWD
info "Current Dir: $CURRENT_DIR"

SERVER=
DB=
USER=
PASSWORD=
SCHEMA=

DB_SETTINGS_FILE=~/.database
[ -f "$DB_SETTINGS_FILE" ]; echo "Using $DB_SETTINGS_FILE"
[ -f "$DB_SETTINGS_FILE" ]; . "$DB_SETTINGS_FILE"
[ -f "$DB_SETTINGS_FILE" ]; info "Using $DB_SETTINGS_FILE"
[ -f "$DB_SETTINGS_FILE" ]
# shellcheck disable=SC1090
. "$DB_SETTINGS_FILE"

# shellcheck disable=SC2046
LOCAL_DB_SETTINGS_FILE=$(find $(CP="${PWD}"; while [ -n "$CP" ] ; do echo "$CP"; CP="${CP%/*}"; done;) -mindepth 1 -maxdepth 1 -type f -name ".database" | head -n 1)
if [ ! -z "$LOCAL_DB_SETTINGS_FILE" ]; then
if [ -n "$LOCAL_DB_SETTINGS_FILE" ]; then
LOCAL_DB_SETTINGS_FILE=$(readlink -f "$LOCAL_DB_SETTINGS_FILE")
LOCAL_DB_SETTINGS_FOLDER=$(dirname "$LOCAL_DB_SETTINGS_FILE")
if [ "$LOCAL_DB_SETTINGS_FILE" != "$DB_SETTINGS_FILE" ]; then
echo "Using settings from $LOCAL_DB_SETTINGS_FOLDER"
info "Using settings from $LOCAL_DB_SETTINGS_FOLDER"
# shellcheck disable=SC1090
. "$LOCAL_DB_SETTINGS_FILE"
if [ ! -z "$DB" ]; then

if [ -n "$DB" ]; then
[ -z "$SOURCE" ] && SOURCE="$LOCAL_DB_SETTINGS_FOLDER/db"
REDGATE=~/.redgate
[ ! -d "$REDGATE" ] && mkdir $REDGATE
[ ! -d "$REDGATE" ] && mkdir "$REDGATE"
[ -z "$OUTPUT" ] && OUTPUT=$REDGATE/$DB.sql
fi
fi
Expand Down Expand Up @@ -62,14 +84,14 @@ while [ $# -gt 0 ]; do
shift # past argument
shift # past value
;;
*) # unknown option - skip here
*) # unknown option - skip here
shift # past argument
;;
esac
done
}

parse_cmdline $@
parse_cmdline "$@"

[ -z "$SERVER" ] && die "--server not specified"
[ -z "$USER" ] && die "--user not specified"
Expand All @@ -78,14 +100,13 @@ parse_cmdline $@
SQLCOMPARE_SERVER=$SERVER
if [ "$SERVER" = "localhost" ]; then
SQLCOMPARE_SERVER=$(sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mssql)
if [ ! -z "$SQLCOMPARE_SERVER" ]; then
echo "Overriding localhost with Docker Server for compare at $SQLCOMPARE_SERVER"
fi
if [ -n "$SQLCOMPARE_SERVER" ]; then
info "Overriding localhost with Docker Server for compare at $SQLCOMPARE_SERVER"
fi
fi

echo "Server: $SERVER"
echo "User: $USER"
[ ! -z "$DB" ] && echo "DB: $DB"
[ ! -z "$SOURCE" ] && echo "Source: $SOURCE"
[ ! -z "$OUTPUT" ] && echo "Output: $OUTPUT"

info "Server: $SERVER"
info "User: $USER"
[ -n "$DB" ] && info "DB: $DB"
[ -n "$SOURCE" ] && info "Source: $SOURCE"
[ -n "$OUTPUT" ] && info "Output: $OUTPUT"
14 changes: 4 additions & 10 deletions db/dropmssqldb
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#!/bin/sh

die() {
echo
echo "$@"
exit 1
}

BASEDIR="$(dirname "$(readlink -f "$0")")"
echo "Script Dir: $BASEDIR"
SERVER=
DB=

# Not following:
# Not following:
# shellcheck disable=1091
. "$BASEDIR/dbenv"
. "$BASEDIR/dbenv"

info "Script Dir: $BASEDIR"

[ -z "$SERVER" ] && die "--server not specified"
[ -z "$DB" ] && die "--database not specified"
Expand All @@ -23,4 +18,3 @@ DB=

sqlcmd -C -S "$SERVER" -U "$USER" -P "$PASSWORD" -b -e -Q "IF EXISTS(SELECT Name from sys.Databases WHERE name = '$DB') ALTER DATABASE $DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
sqlcmd -C -S "$SERVER" -U "$USER" -P "$PASSWORD" -b -e -Q "IF EXISTS(SELECT Name from sys.Databases WHERE name = '$DB') DROP DATABASE $DB"

16 changes: 5 additions & 11 deletions db/extractdb
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#!/bin/sh

die() {
echo
echo "$@"
exit 1
}

BASEDIR="$(dirname "$(readlink -f "$0")")"
echo "Script Dir: $BASEDIR"
SERVER=
DB=

# Not following:
# Not following:
# shellcheck disable=1091
. "$BASEDIR/dbenv"
. "$BASEDIR/dbenv"

info "Script Dir: $BASEDIR"

while [ $# -gt 0 ]; do
key="$1"
Expand Down Expand Up @@ -94,7 +89,7 @@ EOF


cat << EOF > "$DBXML"
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<!-- -->
<ISOCCompareLocation version="2" type="WorkingFolderGenericLocation" >
<LocalRepositoryFolder>%SOURCE%</LocalRepositoryFolder>
Expand All @@ -115,4 +110,3 @@ sudo "$BASEDIR/sqlcompare" \
/database1:"$DB" \
/username1:"$USER" \
/password1:"$PASSWORD"

4 changes: 2 additions & 2 deletions db/install-mssql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "Script Dir: $BASEDIR"

cd "$BASEDIR" || die "Could not select $BASEDIR"

# Not following:
# Not following:
# shellcheck disable=1091
. "$BASEDIR/dbenv"

Expand All @@ -25,7 +25,7 @@ while [ $# -gt 0 ]; do
shift # past argument
shift # past value
;;
*) # unknown option - skip here
*) # unknown option - skip here
shift # past argument
;;
esac
Expand Down
6 changes: 2 additions & 4 deletions db/sqlcompare
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ echo "docker run --rm \
-e REDGATE_LICENSING_PAT_TOKEN=$REDGATE_PAT \
redgate/sqlcompare:$SQLCOMPARE_VERSION \
/IAgreeToTheEULA \
$*"
$*"
docker run --rm \
--interactive \
--tty \
--mount "type=bind,src=$USER_HOME,dst=$USER_HOME" \
--network multi-host-network \
"redgate/sqlcompare:$SQLCOMPARE_VERSION" \
"$@"


"$@"
17 changes: 6 additions & 11 deletions db/updatedb-redgate
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#!/bin/sh

die() {
echo
echo "$@"
exit 1
}

BASEDIR="$(dirname "$(readlink -f "$0")")"
echo "Script Dir: $BASEDIR"
SOURCE=
SERVER=
USER=
Expand All @@ -16,10 +9,12 @@ OUTPUT=
REPORT=
LOG=

# Not following:
# Not following:
# shellcheck disable=1091
. "$BASEDIR/dbenv"

info "Script Dir: $BASEDIR"

while [ $# -gt 0 ]; do
key="$1"

Expand Down Expand Up @@ -65,7 +60,7 @@ REPORT="$OUTPUT.xml"
# "/email:$REDGATE_EMAIL" \
# "/token:$REDGATE_PAT" \

echo "Running sqlcompare to produce $OUTPUT"
info "Running sqlcompare to produce $OUTPUT"
sudo "$BASEDIR/sqlcompare" \
"$HOME" \
"/email:$REDGATE_EMAIL" \
Expand All @@ -91,7 +86,7 @@ sudo "$BASEDIR/sqlcompare" \
/username2:"$USER" \
/password2:"$PASSWORD"


# \
# /assertidentical

Expand All @@ -104,7 +99,7 @@ sudo "$BASEDIR/sqlcompare" \



echo "Running sqlcmd to import $OUTPUT"
info "Running sqlcmd to import $OUTPUT"
sqlcmd \
-C \
-S "$SQLCOMPARE_SERVER" \
Expand Down
Loading
Loading