From 5bb8dfce0b24dd482488b2b86d84ddc8bdff4985 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Mon, 14 Oct 2024 16:53:48 +0200 Subject: [PATCH 1/3] Add `readOnlyConnectionString` --- docs/getting-started/server/database/ef/index.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/getting-started/server/database/ef/index.mdx b/docs/getting-started/server/database/ef/index.mdx index 1e41894ed..dea2fd14c 100644 --- a/docs/getting-started/server/database/ef/index.mdx +++ b/docs/getting-started/server/database/ef/index.mdx @@ -105,6 +105,9 @@ sure you update the existing values instead of creating new ones ```json "globalSettings:databaseProvider": "postgres", "globalSettings:postgreSql:connectionString": "Host=localhost;Username=postgres;Password=example;Database=vault_dev;Include Error Detail=true", + +// optional, falls back to the above connection string if not set +"globalSettings:postgreSql:readOnlyConnectionString": "Host=localhost;Username=postgres;Password=example;Database=vault_dev;Include Error Detail=true", ``` @@ -116,6 +119,9 @@ sure you update the existing values instead of creating new ones ```json "globalSettings:databaseProvider": "mysql", "globalSettings:mySql:connectionString": "server=localhost;uid=root;pwd=example;database=vault_dev", + +// optional, falls back to the above connection string if not set +"globalSettings:mySql:readOnlyConnectionString": "server=localhost;uid=root;pwd=example;database=vault_dev", ``` @@ -127,6 +133,9 @@ Source path. Use the file location selected in [Database Setup](#database-setup) ```json "globalSettings:databaseProvider": "sqlite", "globalSettings:sqlite:connectionString": "Data Source=/path/to/your/server/repo/dev/db/bitwarden.db", + +// optional, falls back to the above connection string if not set +"globalSettings:sqlite:readOnlyConnectionString": "Data Source=/path/to/your/server/repo/dev/db/bitwarden.db", ``` From 7d61a412e4ea44e12ee3b4625b5d2f928e6fc757 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Thu, 17 Oct 2024 13:13:59 +0200 Subject: [PATCH 2/3] Revert "Add `readOnlyConnectionString`" This reverts commit 5bb8dfce0b24dd482488b2b86d84ddc8bdff4985. --- docs/getting-started/server/database/ef/index.mdx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/getting-started/server/database/ef/index.mdx b/docs/getting-started/server/database/ef/index.mdx index dea2fd14c..1e41894ed 100644 --- a/docs/getting-started/server/database/ef/index.mdx +++ b/docs/getting-started/server/database/ef/index.mdx @@ -105,9 +105,6 @@ sure you update the existing values instead of creating new ones ```json "globalSettings:databaseProvider": "postgres", "globalSettings:postgreSql:connectionString": "Host=localhost;Username=postgres;Password=example;Database=vault_dev;Include Error Detail=true", - -// optional, falls back to the above connection string if not set -"globalSettings:postgreSql:readOnlyConnectionString": "Host=localhost;Username=postgres;Password=example;Database=vault_dev;Include Error Detail=true", ``` @@ -119,9 +116,6 @@ sure you update the existing values instead of creating new ones ```json "globalSettings:databaseProvider": "mysql", "globalSettings:mySql:connectionString": "server=localhost;uid=root;pwd=example;database=vault_dev", - -// optional, falls back to the above connection string if not set -"globalSettings:mySql:readOnlyConnectionString": "server=localhost;uid=root;pwd=example;database=vault_dev", ``` @@ -133,9 +127,6 @@ Source path. Use the file location selected in [Database Setup](#database-setup) ```json "globalSettings:databaseProvider": "sqlite", "globalSettings:sqlite:connectionString": "Data Source=/path/to/your/server/repo/dev/db/bitwarden.db", - -// optional, falls back to the above connection string if not set -"globalSettings:sqlite:readOnlyConnectionString": "Data Source=/path/to/your/server/repo/dev/db/bitwarden.db", ``` From 68e829629bc1da15a707f600e84ff8f76f81dbea Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Thu, 17 Oct 2024 13:22:34 +0200 Subject: [PATCH 3/3] Fix --- .../server/database/mssql/index.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/getting-started/server/database/mssql/index.md b/docs/getting-started/server/database/mssql/index.md index be97ca79c..028acc8b5 100644 --- a/docs/getting-started/server/database/mssql/index.md +++ b/docs/getting-started/server/database/mssql/index.md @@ -24,3 +24,24 @@ of your database. The process for modifying the database is described in [Migrations](./../../../../contributing/database-migrations/). + +## Running self-hosted locally + +### SQL Server (Dapper) + +To set up a self-hosted instance locally, you should follow the instructions +[here](../self-hosted/). Assuming you've defined your user secrets as described in the +[User Secrets](../../user-secrets/) documentation, you'll find that if you don't define the +`readOnlyConnectionString` override as shown below, your self-hosted instance will fall back to use +the regular/default connection string. This can result in unexpected behavior as your self-hosted +instance will be reading from the wrong database. + +You can simply copy whatever value you have for `connectionString` and copy it to +`readOnlyConnectionString` in your secrets.json file. + +```json +{ + "dev:selfHostOverride:globalSettings:sqlServer:connectionString": "Server=localhost;Database=vault_dev_self_host;User Id=sa;Password=your_password_here", + "dev:selfHostOverride:globalSettings:sqlServer:readOnlyConnectionString": "Server=localhost;Database=vault_dev_self_host;User Id=sa;Password=your_password_here" +} +```