Fix unlinked auth profile/image relation after enabling module-migration inheritance
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
調査の方向性
Start by reading the UserProfile.image and UserProfileImage.userProfile relation definitions and the module-migration inheritance path used by consuming projects. Then trace how create-migration handles module SQL and non-breaking classifications, and identify coverage for upgrades of populated databases and transactional data-only restores. Done means the linked relation is migrated without data loss, consuming projects run the custom non-breaking SQL, and the regression scenarios pass.
索引モデルが issue の本文から書いたものです。
説明
Summary
Correct the unlinked relation between UserProfile.image and UserProfileImage.userProfile in serverpod_auth_core, without losing existing profile or image data.
Prerequisite: projects must use the SQL from module migrations rather than regenerating the module's schema changes with serverpod create-migration. This capability must be solved first so a custom, non-destructive module migration reaches consuming projects.
Background and root cause
The relation definitions omit the shared name parameter that would link the two sides:
# UserProfileImage
userProfile: UserProfile?, relation(onDelete=Cascade)
# UserProfile
image: UserProfileImage?, relation(optional, deferred)
This creates two independent foreign keys and an unintended circular reference:
serverpod_auth_core_profile.imageIdreferencesserverpod_auth_core_profile_image.id.serverpod_auth_core_profile_image.userProfileIdreferencesserverpod_auth_core_profile.id.
The cycle broke data-only restores, as described in #5767. PR #5771 made the profile-image foreign-key check deferred to commit, allowing a transactional pg_restore to succeed. That was a workaround for restoration, not a correction of the missing relation name.
Why module-migration inheritance must come first
As explained in the linked discussion, adding the missing relation name under the current migration system produces a destructive schema migration that drops data. A custom SQL migration could preserve the existing data, but consuming projects currently regenerate module changes during create-migration instead of inheriting the module's migration SQL. Consequently, the custom data-preserving transformation would not reach those projects.
The prerequisite must:
- Make project migrations inherit/use the SQL from the corresponding module migrations instead of rebuilding those changes solely from the schema diff.
- Preserve custom module SQL, including transformations that turn a destructive generated migration into a non-destructive one.
- Honor the module migration's non-breaking classification when creating the project migration.
The discussion also notes that the same limitation could affect future offline-sync metadata schema evolution, but that is supporting context rather than additional scope for this issue.
Proposed implementation order
- Solve module-migration inheritance for consuming projects, including preservation of custom SQL and non-breaking classification.
- Link
UserProfile.imageandUserProfileImage.userProfileusing the appropriate shared relation name. - Provide a custom, non-destructive module migration that preserves existing users, profiles, images, and their associations; verify that consuming projects actually execute it.
Acceptance criteria
- The two model fields describe the intended linked relation rather than two accidentally independent relations.
- Upgrading a consuming project preserves existing users, profiles, image records, and profile/image associations, including profiles without an image.
- The consuming project's migration uses the module's custom SQL and honors its non-breaking classification.
- Regression coverage exercises an existing populated database upgraded through the consuming-project migration path, not just a fresh module database.
- The transactional data-only restore behavior fixed by #5771 remains working.
Initiative context and references
- Requested by Marcelo in the Slack discussion.
- Workaround: https://github.com/serverpod/serverpod/pull/5771
- Original restore issue: https://github.com/serverpod/serverpod/issues/5767
- 主要言語
- Dart
- スター
- 3.3k
- フォーク
- 382
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 62
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
serverpod/serverpod のほかの issue
-
area: web server enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
area: configuration area: runtime
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
serverpod/serverpod#3749 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: cli enhancement stake: onboarding
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
メンテナーはふだん 1 日以内に返信
-
area: database enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
serverpod/serverpod#3442 · コメント 4 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
serverpod/serverpod#5834 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
serverpod/serverpod の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OpenBikeControl/bikecontrol#404 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Language picker in Settings doesn't scroll; last languages overlap the buttons対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbacklog:medium bug localization
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
simonoppowa/OpenNutriTracker#1331 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
MunichWays/munich-ways-app#248 ·
-
feature
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
lollipopkit/flutter_server_box#1659 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100