Replace foreign keys with indexes, document no-FK convention#38
Replace foreign keys with indexes, document no-FK convention#38HamptonMakes merged 2 commits intomainfrom
Conversation
The engine's authenticate_coplan_user! was returning a bare 401 Unauthorized when the auth callback returned nil. For host apps with a login page (like this dev host), users should be redirected to sign in instead. - Add sign_in_path config option to CoPlan::Configuration - Redirect to sign_in_path when set, fall back to head :unauthorized - Configure /sign_in in the host app initializer Amp-Thread-ID: https://ampcode.com/threads/T-019cb4db-952a-7559-9ee4-15fcdd27cb1b Co-authored-by: Amp <amp@ampcode.com>
ODS/Aurora app DB user lacks REFERENCES privilege. Replace all add_foreign_key calls with indexes. Added no-FK rule to AGENTS.md. Amp-Thread-ID: https://ampcode.com/threads/T-019cb0b8-a827-777c-954c-f375b6d8e9f7 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 631de62f86
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| add_index :coplan_plans, :created_by_user_id | ||
| add_foreign_key :coplan_plans, :coplan_users, column: :created_by_user_id | ||
|
|
There was a problem hiding this comment.
Sync installed migration copy with FK removal
This commit removes add_foreign_key calls only in engine/db/migrate/20260226200000_create_coplan_schema.rb, but the repository still contains the installed migration copy at db/migrate/20260226200000_create_coplan_schema.co_plan.rb with all of the original FK statements (for example at lines 29, 52, 69, etc.). In environments that run the copied app migration (which is exactly the case once coplan:install:migrations has been used, and this repo already has that copy), db:migrate will still execute FK DDL and hit the same REFERENCES-privilege failure, so the migration fix is effectively not applied.
Useful? React with 👍 / 👎.
The ODS/Aurora
appDB user in coplan-square lacksREFERENCESprivilege, soadd_foreign_keycalls fail during migration.Migration: Replace all 15 FK constraints with indexes on relationship columns.
AGENTS.md: Added no-FK convention to Database Conventions section so future migrations don't use
add_foreign_key.