mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-10 01:10:42 +03:00
[PR #863] [MERGED] fix: enable foreign key check for sqlite #574
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/pocket-id/pocket-id/pull/863
Author: @stonith404
Created: 8/22/2025
Status: ✅ Merged
Merged: 8/23/2025
Merged by: @stonith404
Base:
main← Head:fix/foreign-keys📝 Commits (7)
86dc5a5enable foreign key checks in sqlitede4b6b6add missing foreign keys and adapt sync postgres foreign key constraintse58c5aeuse pointers for user id7404c0fMerge branch 'main' into fix/foreign-keyscae81d8Parse the SQLite connection string to set default optionsaac2573Apply suggestion from @ItalyPaleAlef355a7fMerge branch 'main' of https://github.com/pocket-id/pocket-id into fix/foreign-keys📊 Changes
10 files changed (+545 additions, -48 deletions)
View changed files
📝
backend/internal/bootstrap/db_bootstrap.go(+138 -9)📝
backend/internal/bootstrap/db_bootstrap_test.go(+216 -31)📝
backend/internal/common/env_config.go(+1 -1)📝
backend/internal/model/oidc.go(+2 -2)📝
backend/internal/service/e2etest_service.go(+4 -4)📝
backend/internal/service/oidc_service.go(+1 -1)➕
backend/resources/migrations/postgres/20250822000000_foreign_keys_improvements.down.sql(+1 -0)➕
backend/resources/migrations/postgres/20250822000000_foreign_keys_improvements.up.sql(+8 -0)➕
backend/resources/migrations/sqlite/20250822000000_foreign_keys_improvements.down.sql(+1 -0)➕
backend/resources/migrations/sqlite/20250822000000_foreign_keys_improvements.up.sql(+173 -0)📄 Description
By default Sqlite doesn't enforce foreign key checks which can lead to orphan rows in the database and confusing behavior. This changes the default connection string of Sqlite so that the connections enforce foreign key checks.
For this change I have added a migration, that cleans all potential orphan rows, adds missing foreign keys and brings the
ON DELETEbehavior of Postgres and Sqlite in sync.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.