[PR #621] [MERGED] Adds support for PostgreSQL which adds #87 and is mentioned in #246. #6404

Closed
opened 2026-03-07 20:58:29 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/621
Author: @swedishborgie
Created: 9/12/2019
Status: Merged
Merged: 9/16/2019
Merged by: @dani-garcia

Base: masterHead: postgresql


📝 Commits (1)

  • f5f9861 Adds support for PostgreSQL which resolves #87 and is mentioned in #246.

📊 Changes

18 files changed (+724 additions, -12 deletions)

View changed files

📝 Cargo.lock (+12 -0)
📝 Cargo.toml (+4 -0)
📝 build.rs (+6 -2)
docker/amd64/postgresql/Dockerfile (+103 -0)
docker/amd64/postgresql/Dockerfile.alpine (+85 -0)
migrations/postgresql/2019-09-12-100000_create_tables/down.sql (+13 -0)
migrations/postgresql/2019-09-12-100000_create_tables/up.sql (+121 -0)
📝 src/db/mod.rs (+5 -0)
📝 src/db/models/attachment.rs (+14 -2)
📝 src/db/models/cipher.rs (+16 -1)
📝 src/db/models/collection.rs (+48 -1)
📝 src/db/models/device.rs (+13 -1)
📝 src/db/models/folder.rs (+27 -1)
📝 src/db/models/organization.rs (+34 -2)
📝 src/db/models/two_factor.rs (+13 -1)
📝 src/db/models/user.rs (+34 -1)
src/db/schemas/postgresql/schema.rs (+172 -0)
📝 src/main.rs (+4 -0)

📄 Description

The biggest change to existing code is that replace_into() isn't supported by Diesel for the PostgreSQL back end, instead requiring the use of on_conflict(). This unfortunately requires a branch for save() on most of the models and requires PostgreSQL >= 9.5.

I've included Dockerfile's for amd64 for both the Debian and Alpine variants, it should be straight forward to create new files for the other architectures but I don't currently have access to the other architectures and I didn't want to submit anything untested.

I've only done a couple hours worth of testing but everything seems to work. The migration SQL and model schema are both very similar to the existing two back ends.

Please let me know if you'd like any changes or if I missed anything.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/621 **Author:** [@swedishborgie](https://github.com/swedishborgie) **Created:** 9/12/2019 **Status:** ✅ Merged **Merged:** 9/16/2019 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `master` ← **Head:** `postgresql` --- ### 📝 Commits (1) - [`f5f9861`](https://github.com/dani-garcia/vaultwarden/commit/f5f9861a78c1a4b6322e27739e7886d8d0f15759) Adds support for PostgreSQL which resolves #87 and is mentioned in #246. ### 📊 Changes **18 files changed** (+724 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+12 -0) 📝 `Cargo.toml` (+4 -0) 📝 `build.rs` (+6 -2) ➕ `docker/amd64/postgresql/Dockerfile` (+103 -0) ➕ `docker/amd64/postgresql/Dockerfile.alpine` (+85 -0) ➕ `migrations/postgresql/2019-09-12-100000_create_tables/down.sql` (+13 -0) ➕ `migrations/postgresql/2019-09-12-100000_create_tables/up.sql` (+121 -0) 📝 `src/db/mod.rs` (+5 -0) 📝 `src/db/models/attachment.rs` (+14 -2) 📝 `src/db/models/cipher.rs` (+16 -1) 📝 `src/db/models/collection.rs` (+48 -1) 📝 `src/db/models/device.rs` (+13 -1) 📝 `src/db/models/folder.rs` (+27 -1) 📝 `src/db/models/organization.rs` (+34 -2) 📝 `src/db/models/two_factor.rs` (+13 -1) 📝 `src/db/models/user.rs` (+34 -1) ➕ `src/db/schemas/postgresql/schema.rs` (+172 -0) 📝 `src/main.rs` (+4 -0) </details> ### 📄 Description The biggest change to existing code is that `replace_into()` isn't supported by Diesel for the PostgreSQL back end, instead requiring the use of `on_conflict()`. This unfortunately requires a branch for `save()` on most of the models and requires PostgreSQL >= 9.5. I've included `Dockerfile`'s for amd64 for both the Debian and Alpine variants, it should be straight forward to create new files for the other architectures but I don't currently have access to the other architectures and I didn't want to submit anything untested. I've only done a couple hours worth of testing but everything seems to work. The migration SQL and model schema are both very similar to the existing two back ends. Please let me know if you'd like any changes or if I missed anything. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-07 20:58:29 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#6404