By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description (generated by Copilot)
This pull request improves the robustness and idempotency of the 1.17.0 database migration scripts for both PostgreSQL and SQLite backends. The changes ensure that migrations can be safely run on databases that may already have some schema changes applied (such as from release candidate upgrades), preventing crashes and errors due to missing columns or constraints.
Added guards when querying roleId columns from userOrgs and userInvites to handle cases where the columns may have already been removed, preventing migration failures on partially-upgraded schemas.
Changed DROP CONSTRAINT and DROP COLUMN statements to use IF EXISTS, making the migration idempotent and preventing errors if the constraints or columns are already absent. [1][2][3]
Checked for the existence of roleId columns in userOrgs and userInvites tables before querying, ensuring migrations work even if those columns were already dropped in previous upgrades.
Used CREATE TABLE IF NOT EXISTS and CREATE UNIQUE INDEX IF NOT EXISTS for new tables and indexes to avoid errors if the migration is re-run. [1][2][3]
Added DROP TABLE IF EXISTS statements before creating temporary tables to ensure a clean migration state. [1][2]
How to test?
Run Migration
🔄 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/fosrl/pangolin/pull/2769
**Author:** [@marcschaeferger](https://github.com/marcschaeferger)
**Created:** 4/2/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `rc-fixes`
---
### 📝 Commits (3)
- [`fef9bd6`](https://github.com/fosrl/pangolin/commit/fef9bd65e5527c5bcd7a4f5072508d57ce11fd54) fix(migration/postgres): Update migration script to handle column removals safely
- [`453876b`](https://github.com/fosrl/pangolin/commit/453876b8b4e257f26537b70d374968b8702b65f2) fix(migration/sqlite): Refactor roleId handling in userOrg and userInvite migrations
- [`38d24d4`](https://github.com/fosrl/pangolin/commit/38d24d43a436e0767b1d0bb13dbdf6e83c6618ee) Fix catch blocks in 1.17.0 migration to only swallow missing-column errors
### 📊 Changes
**2 files changed** (+94 additions, -30 deletions)
<details>
<summary>View changed files</summary>
📝 `server/setup/scriptsPg/1.17.0.ts` (+51 -16)
📝 `server/setup/scriptsSqlite/1.17.0.ts` (+43 -14)
</details>
### 📄 Description
## Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
## Description (generated by Copilot)
This pull request improves the robustness and idempotency of the 1.17.0 database migration scripts for both PostgreSQL and SQLite backends. The changes ensure that migrations can be safely run on databases that may already have some schema changes applied (such as from release candidate upgrades), preventing crashes and errors due to missing columns or constraints.
**PostgreSQL migration script improvements (`server/setup/scriptsPg/1.17.0.ts`):**
* Added guards when querying `roleId` columns from `userOrgs` and `userInvites` to handle cases where the columns may have already been removed, preventing migration failures on partially-upgraded schemas.
* Changed `DROP CONSTRAINT` and `DROP COLUMN` statements to use `IF EXISTS`, making the migration idempotent and preventing errors if the constraints or columns are already absent. [[1]](diffhunk://#diff-a329ba1abb0c9766012185262aefb8f56a6e6bc9a4119a66a74995a9008d2550L108-R127) [[2]](diffhunk://#diff-a329ba1abb0c9766012185262aefb8f56a6e6bc9a4119a66a74995a9008d2550L119-R141) [[3]](diffhunk://#diff-a329ba1abb0c9766012185262aefb8f56a6e6bc9a4119a66a74995a9008d2550L179-R198)
**SQLite migration script improvements (`server/setup/scriptsSqlite/1.17.0.ts`):**
* Checked for the existence of `roleId` columns in `userOrgs` and `userInvites` tables before querying, ensuring migrations work even if those columns were already dropped in previous upgrades.
* Used `CREATE TABLE IF NOT EXISTS` and `CREATE UNIQUE INDEX IF NOT EXISTS` for new tables and indexes to avoid errors if the migration is re-run. [[1]](diffhunk://#diff-db717df51f45b096d2c284f5c3c4563878c122a0b64af0bb4f71877e7aeb65faL112-R139) [[2]](diffhunk://#diff-db717df51f45b096d2c284f5c3c4563878c122a0b64af0bb4f71877e7aeb65faL124-R154) [[3]](diffhunk://#diff-db717df51f45b096d2c284f5c3c4563878c122a0b64af0bb4f71877e7aeb65faL150-R178)
* Added `DROP TABLE IF EXISTS` statements before creating temporary tables to ensure a clean migration state. [[1]](diffhunk://#diff-db717df51f45b096d2c284f5c3c4563878c122a0b64af0bb4f71877e7aeb65faL124-R154) [[2]](diffhunk://#diff-db717df51f45b096d2c284f5c3c4563878c122a0b64af0bb4f71877e7aeb65faR187)
## How to test?
Run Migration
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/fosrl/pangolin/pull/2769
Author: @marcschaeferger
Created: 4/2/2026
Status: ❌ Closed
Base:
main← Head:rc-fixes📝 Commits (3)
fef9bd6fix(migration/postgres): Update migration script to handle column removals safely453876bfix(migration/sqlite): Refactor roleId handling in userOrg and userInvite migrations38d24d4Fix catch blocks in 1.17.0 migration to only swallow missing-column errors📊 Changes
2 files changed (+94 additions, -30 deletions)
View changed files
📝
server/setup/scriptsPg/1.17.0.ts(+51 -16)📝
server/setup/scriptsSqlite/1.17.0.ts(+43 -14)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description (generated by Copilot)
This pull request improves the robustness and idempotency of the 1.17.0 database migration scripts for both PostgreSQL and SQLite backends. The changes ensure that migrations can be safely run on databases that may already have some schema changes applied (such as from release candidate upgrades), preventing crashes and errors due to missing columns or constraints.
PostgreSQL migration script improvements (
server/setup/scriptsPg/1.17.0.ts):roleIdcolumns fromuserOrgsanduserInvitesto handle cases where the columns may have already been removed, preventing migration failures on partially-upgraded schemas.DROP CONSTRAINTandDROP COLUMNstatements to useIF EXISTS, making the migration idempotent and preventing errors if the constraints or columns are already absent. [1] [2] [3]SQLite migration script improvements (
server/setup/scriptsSqlite/1.17.0.ts):roleIdcolumns inuserOrgsanduserInvitestables before querying, ensuring migrations work even if those columns were already dropped in previous upgrades.CREATE TABLE IF NOT EXISTSandCREATE UNIQUE INDEX IF NOT EXISTSfor new tables and indexes to avoid errors if the migration is re-run. [1] [2] [3]DROP TABLE IF EXISTSstatements before creating temporary tables to ensure a clean migration state. [1] [2]How to test?
Run Migration
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.