Consolidate engine migrations and collapse host User into CoPlan::User#35
Conversation
- Replace 18 host migrations + 1 partial engine migration with a single engine migration (create_coplan_schema) that creates all 10 coplan_* tables from scratch. New hosts just install the engine and migrate. - Remove host User model entirely. CoPlan::User is now the single user model with email added for Slack DM support. - Update SessionsController, ApplicationController, CoPlan auth callback, SlackNotificationJob, ActiveAdmin, seeds, and specs to use CoPlan::User. - Root route now points to plans#index instead of dashboard#show. - Add 'My Plans' / 'All Plans' filter to plans index page. Amp-Thread-ID: https://ampcode.com/threads/T-019ca0be-66f9-715f-8d94-944467f13298 Co-authored-by: Amp <[email protected]>
15b9dc2 to
70e6720
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15b9dc2232
ℹ️ 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".
| @@ -0,0 +1,173 @@ | |||
| class CreateCoplanSchema < ActiveRecord::Migration[8.1] | |||
There was a problem hiding this comment.
Use a new migration version for consolidated schema
This migration reuses version 20260226200000, which was already used by the deleted create_coplan_users migration; hosts that already ran that old version will have 20260226200000 recorded in schema_migrations, so db:migrate will skip this new consolidated migration entirely and never create/add the new schema pieces (including coplan_users.email and the other tables), leaving upgraded installs broken.
Useful? React with 👍 / 👎.
| ActiveAdmin.register User do | ||
| permit_params :email, :name, :role | ||
| ActiveAdmin.register CoPlan::User, as: "User" do | ||
| permit_params :name, :email, :admin |
There was a problem hiding this comment.
Permit external_id in ActiveAdmin user params
CoPlan::User now validates external_id as required, but this ActiveAdmin resource only permits :name, :email, and :admin; creating a user from /admin/users/new will submit without external_id and fail validation, so the admin UI's user creation path is effectively broken.
Useful? React with 👍 / 👎.
What
Replace 18 host migrations + 1 partial engine migration with a single engine migration (
create_coplan_schema) that creates all 10coplan_*tables from scratch. New hosts just install the engine and migrate — no more ghost tables or rename dependencies.Remove host
Usermodel entirely.CoPlan::Useris now the single user model withemailadded for Slack DM support.Update
SessionsController,ApplicationController, CoPlan auth callback,SlackNotificationJob, ActiveAdmin, seeds, and specs to useCoPlan::Userdirectly.Root route →
plans#indexinstead ofdashboard#show.Add "My Plans" / "All Plans" filter to plans index page.
Why
A fresh hosted CoPlan couldn't run migrations — the engine only had a migration for
coplan_users, so all other tables (includingcoplan_api_tokens) were missing. The host migrations assumed pre-existing tables to rename, which don't exist on a new deploy.Testing
bundle exec rspec— 386 examples, 0 failures.