From c57091c4b1009276faf8a3662603644eac83a4f6 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Mon, 10 Jun 2024 12:47:22 -0600
Subject: [PATCH 1/2] [deps] DbOps: Update Microsoft.Data.SqlClient to v5.2.1
(#4170)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
src/Core/Core.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index f0fcecd9fd..ee4d65744e 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -37,7 +37,7 @@
-
+
From a60f70dde5d44de08cadc923f394fb575cf56b1d Mon Sep 17 00:00:00 2001
From: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
Date: Tue, 11 Jun 2024 06:25:52 +1000
Subject: [PATCH 2/2] [AC-2300] Remove mssql utility migration record migrator
(#4171)
* Remove mssql utility migration record migrator
* Remove old/unused files
---
dev/helpers/mssql/migrate_migrations.sh | 48 -------------------------
dev/migrate.ps1 | 9 -----
dev/migrate_migration_record.ps1 | 21 -----------
util/Migrator/createVaultDev.sh | 21 -----------
4 files changed, 99 deletions(-)
delete mode 100755 dev/helpers/mssql/migrate_migrations.sh
delete mode 100755 dev/migrate_migration_record.ps1
delete mode 100644 util/Migrator/createVaultDev.sh
diff --git a/dev/helpers/mssql/migrate_migrations.sh b/dev/helpers/mssql/migrate_migrations.sh
deleted file mode 100755
index f8993bc145..0000000000
--- a/dev/helpers/mssql/migrate_migrations.sh
+++ /dev/null
@@ -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"
diff --git a/dev/migrate.ps1 b/dev/migrate.ps1
index 9aec956dbc..03890b555f 100755
--- a/dev/migrate.ps1
+++ b/dev/migrate.ps1
@@ -1,9 +1,6 @@
#!/usr/bin/env pwsh
# Creates the vault_dev database, and runs all the migrations.
-# Due to azure-edge-sql not containing the mssql-tools on ARM, we manually use
-# the mssql-tools container which runs under x86_64.
-
param(
[switch]$all,
[switch]$postgres,
@@ -36,15 +33,9 @@ if ($all -or $mssql) {
if ($selfhost) {
$msSqlConnectionString = $(Get-UserSecrets).'dev:selfHostOverride:globalSettings:sqlServer:connectionString'
$envName = "self-host"
-
- Write-Output "Migrating your migrations to use MsSqlMigratorUtility (if needed)"
- ./migrate_migration_record.ps1 -s
} else {
$msSqlConnectionString = $(Get-UserSecrets).'globalSettings:sqlServer:connectionString'
$envName = "cloud"
-
- Write-Output "Migrating your migrations to use MsSqlMigratorUtility (if needed)"
- ./migrate_migration_record.ps1
}
Write-Host "Starting Microsoft SQL Server Migrations for $envName"
diff --git a/dev/migrate_migration_record.ps1 b/dev/migrate_migration_record.ps1
deleted file mode 100755
index 17521edf92..0000000000
--- a/dev/migrate_migration_record.ps1
+++ /dev/null
@@ -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
diff --git a/util/Migrator/createVaultDev.sh b/util/Migrator/createVaultDev.sh
deleted file mode 100644
index 1d920bfb4d..0000000000
--- a/util/Migrator/createVaultDev.sh
+++ /dev/null
@@ -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;