Browse Source
ac-2385-as-a-billing-system-I-need-to-handle-attempting-to-pay-an-invoice-with-braintree-for-a-provider
5 changed files with 1 additions and 100 deletions
@ -1,48 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
# |
|
||||||
# !!! UPDATED 2024 for MsSqlMigratorUtility !!! |
|
||||||
# |
|
||||||
# There seems to be [a bug with docker-compose](https://github.com/docker/compose/issues/4076#issuecomment-324932294) |
|
||||||
# where it takes ~40ms to connect to the terminal output of the container, so stuff logged to the terminal in this time is lost. |
|
||||||
# The best workaround seems to be adding tiny delay like so: |
|
||||||
sleep 0.1; |
|
||||||
|
|
||||||
SERVER='mssql' |
|
||||||
DATABASE="vault_dev" |
|
||||||
USER="SA" |
|
||||||
PASSWD=$MSSQL_PASSWORD |
|
||||||
|
|
||||||
while getopts "s" arg; do |
|
||||||
case $arg in |
|
||||||
s) |
|
||||||
echo "Running for self-host environment" |
|
||||||
DATABASE="vault_dev_self_host" |
|
||||||
;; |
|
||||||
esac |
|
||||||
done |
|
||||||
|
|
||||||
QUERY="IF OBJECT_ID('[$DATABASE].[dbo].[Migration]') IS NULL AND OBJECT_ID('[migrations_$DATABASE].[dbo].[migrations]') IS NOT NULL |
|
||||||
BEGIN |
|
||||||
-- Create [database].dbo.Migration with the schema expected by MsSqlMigratorUtility |
|
||||||
SET ANSI_NULLS ON; |
|
||||||
SET QUOTED_IDENTIFIER ON; |
|
||||||
|
|
||||||
CREATE TABLE [$DATABASE].[dbo].[Migration]( |
|
||||||
[Id] [int] IDENTITY(1,1) NOT NULL, |
|
||||||
[ScriptName] [nvarchar](255) NOT NULL, |
|
||||||
[Applied] [datetime] NOT NULL |
|
||||||
) ON [PRIMARY]; |
|
||||||
|
|
||||||
ALTER TABLE [$DATABASE].[dbo].[Migration] ADD CONSTRAINT [PK_Migration_Id] PRIMARY KEY CLUSTERED |
|
||||||
( |
|
||||||
[Id] ASC |
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]; |
|
||||||
|
|
||||||
-- Copy across old data |
|
||||||
INSERT INTO [$DATABASE].[dbo].[Migration] (ScriptName, Applied) |
|
||||||
SELECT CONCAT('Bit.Migrator.DbScripts.', [Filename]), CreationDate |
|
||||||
FROM [migrations_$DATABASE].[dbo].[migrations]; |
|
||||||
END |
|
||||||
" |
|
||||||
|
|
||||||
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d master -U $USER -P $PASSWD -I -Q "$QUERY" |
|
||||||
@ -1,21 +0,0 @@ |
|||||||
#!/usr/bin/env pwsh |
|
||||||
# !!! UPDATED 2024 for MsSqlMigratorUtility !!! |
|
||||||
# |
|
||||||
# This is a migration script to move data from [migrations_vault_dev].[dbo].[migrations] (used by our custom |
|
||||||
# migrator script) to [vault_dev].[dbo].[Migration] (used by MsSqlMigratorUtility). It is safe to run multiple |
|
||||||
# times because it will not perform any migration if it detects that the new table is already present. |
|
||||||
# This will be deleted after a few months after everyone has (presumably) migrated to the new schema. |
|
||||||
|
|
||||||
# Due to azure-edge-sql not containing the mssql-tools on ARM, we manually use |
|
||||||
# the mssql-tools container which runs under x86_64. |
|
||||||
|
|
||||||
docker run ` |
|
||||||
-v "$(pwd)/helpers/mssql:/mnt/helpers" ` |
|
||||||
-v "$(pwd)/../util/Migrator:/mnt/migrator/" ` |
|
||||||
-v "$(pwd)/.data/mssql:/mnt/data" ` |
|
||||||
--env-file .env ` |
|
||||||
--network=bitwardenserver_default ` |
|
||||||
--rm ` |
|
||||||
-it ` |
|
||||||
mcr.microsoft.com/mssql-tools ` |
|
||||||
/mnt/helpers/migrate_migrations.sh @args |
|
||||||
@ -1,21 +0,0 @@ |
|||||||
# Creates and populates vault_dev - used for development purposes |
|
||||||
# This should be run from within an empty MSSQL Docker container |
|
||||||
# See instructions in SETUP.md |
|
||||||
|
|
||||||
if [ -z $1 ]; then |
|
||||||
echo "Error: you must provide SA_PASSWORD as the first argument." |
|
||||||
echo "You should wrap your password in single quotes to make sure it is correctly interpreted." |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
MIGRATE_DIRECTORY="/mnt/migrator/DbScripts/" |
|
||||||
SERVER="localhost" |
|
||||||
DATABASE="vault_dev" |
|
||||||
USER="sa" |
|
||||||
PASSWD="$1" |
|
||||||
|
|
||||||
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d master -U $USER -P $PASSWD -I -Q "CREATE DATABASE $DATABASE;" |
|
||||||
|
|
||||||
for f in `ls -v $MIGRATE_DIRECTORY/*.sql`; do |
|
||||||
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d $DATABASE -U $USER -P $PASSWD -I -i $f |
|
||||||
done; |
|
||||||
Loading…
Reference in new issue