Skip to content

Replace foreign keys with indexes, document no-FK convention#38

Merged
HamptonMakes merged 2 commits intomainfrom
hampton/remove-foreign-keys
Mar 3, 2026
Merged

Replace foreign keys with indexes, document no-FK convention#38
HamptonMakes merged 2 commits intomainfrom
hampton/remove-foreign-keys

Conversation

@HamptonMakes
Copy link
Collaborator

The ODS/Aurora app DB user in coplan-square lacks REFERENCES privilege, so add_foreign_key calls 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.

HamptonMakes and others added 2 commits March 3, 2026 13:04
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>
@HamptonMakes HamptonMakes merged commit 225113a into main Mar 3, 2026
3 checks passed
@HamptonMakes HamptonMakes deleted the hampton/remove-foreign-keys branch March 3, 2026 20:31
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 28 to 29
add_index :coplan_plans, :created_by_user_id
add_foreign_key :coplan_plans, :coplan_users, column: :created_by_user_id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant