generated from block/oss-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Stop auto-injecting engine migrations into host migrate paths #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
173 changes: 173 additions & 0 deletions
173
db/migrate/20260226200000_create_coplan_schema.co_plan.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| class CreateCoplanSchema < ActiveRecord::Migration[8.1] | ||
| def change | ||
| create_table :coplan_users, id: { type: :string, limit: 36 } do |t| | ||
| t.string :external_id, null: false | ||
| t.string :email | ||
| t.string :name, null: false | ||
| t.boolean :admin, default: false, null: false | ||
| t.json :metadata | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_users, :external_id, unique: true | ||
| add_index :coplan_users, :email, unique: true | ||
|
|
||
| create_table :coplan_plans, id: { type: :string, limit: 36 } do |t| | ||
| t.string :title, null: false | ||
| t.string :status, default: "brainstorm", null: false | ||
| t.integer :current_revision, default: 0, null: false | ||
| t.string :created_by_user_id, limit: 36, null: false | ||
| t.string :current_plan_version_id, limit: 36 | ||
| t.json :tags | ||
| t.json :metadata | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_plans, :status | ||
| add_index :coplan_plans, :updated_at | ||
| add_index :coplan_plans, :created_by_user_id | ||
| add_foreign_key :coplan_plans, :coplan_users, column: :created_by_user_id | ||
|
|
||
| create_table :coplan_plan_versions, id: { type: :string, limit: 36 } do |t| | ||
| t.string :plan_id, limit: 36, null: false | ||
| t.integer :revision, null: false | ||
| t.text :content_markdown, null: false | ||
| t.string :content_sha256, null: false | ||
| t.text :diff_unified | ||
| t.text :change_summary | ||
| t.text :reason | ||
| t.text :prompt_excerpt | ||
| t.json :operations_json | ||
| t.integer :base_revision | ||
| t.string :actor_id, limit: 36 | ||
| t.string :actor_type, null: false | ||
| t.string :ai_provider | ||
| t.string :ai_model | ||
| t.timestamp :created_at, null: false | ||
| end | ||
|
|
||
| add_index :coplan_plan_versions, :plan_id | ||
| add_index :coplan_plan_versions, [:plan_id, :revision], unique: true | ||
| add_index :coplan_plan_versions, [:plan_id, :created_at] | ||
| add_foreign_key :coplan_plan_versions, :coplan_plans, column: :plan_id | ||
|
|
||
| # Now that coplan_plan_versions exists, add the FK for current_plan_version_id | ||
| add_foreign_key :coplan_plans, :coplan_plan_versions, column: :current_plan_version_id | ||
|
|
||
| create_table :coplan_plan_collaborators, id: { type: :string, limit: 36 } do |t| | ||
| t.string :plan_id, limit: 36, null: false | ||
| t.string :user_id, limit: 36, null: false | ||
| t.string :added_by_user_id, limit: 36 | ||
| t.string :role, null: false | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_plan_collaborators, :plan_id | ||
| add_index :coplan_plan_collaborators, :user_id | ||
| add_index :coplan_plan_collaborators, :added_by_user_id | ||
| add_index :coplan_plan_collaborators, [:plan_id, :user_id], unique: true | ||
| add_foreign_key :coplan_plan_collaborators, :coplan_plans, column: :plan_id | ||
| add_foreign_key :coplan_plan_collaborators, :coplan_users, column: :user_id | ||
| add_foreign_key :coplan_plan_collaborators, :coplan_users, column: :added_by_user_id | ||
|
|
||
| create_table :coplan_comment_threads, id: { type: :string, limit: 36 } do |t| | ||
| t.string :plan_id, limit: 36, null: false | ||
| t.string :plan_version_id, limit: 36, null: false | ||
| t.string :created_by_user_id, limit: 36, null: false | ||
| t.string :resolved_by_user_id, limit: 36 | ||
| t.string :addressed_in_plan_version_id, limit: 36 | ||
| t.string :out_of_date_since_version_id, limit: 36 | ||
| t.string :status, default: "open", null: false | ||
| t.boolean :out_of_date, default: false, null: false | ||
| t.text :anchor_text | ||
| t.text :anchor_context | ||
| t.integer :anchor_start | ||
| t.integer :anchor_end | ||
| t.integer :anchor_revision | ||
| t.integer :start_line | ||
| t.integer :end_line | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_comment_threads, [:plan_id, :status] | ||
| add_index :coplan_comment_threads, [:plan_id, :out_of_date] | ||
| add_foreign_key :coplan_comment_threads, :coplan_plans, column: :plan_id | ||
| add_foreign_key :coplan_comment_threads, :coplan_plan_versions, column: :plan_version_id | ||
| add_foreign_key :coplan_comment_threads, :coplan_plan_versions, column: :addressed_in_plan_version_id | ||
| add_foreign_key :coplan_comment_threads, :coplan_plan_versions, column: :out_of_date_since_version_id | ||
| add_foreign_key :coplan_comment_threads, :coplan_users, column: :created_by_user_id | ||
| add_foreign_key :coplan_comment_threads, :coplan_users, column: :resolved_by_user_id | ||
|
|
||
| create_table :coplan_comments, id: { type: :string, limit: 36 } do |t| | ||
| t.string :comment_thread_id, limit: 36, null: false | ||
| t.string :author_id, limit: 36 | ||
| t.string :author_type, null: false | ||
| t.string :agent_name | ||
| t.text :body_markdown, null: false | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_comments, [:comment_thread_id, :created_at] | ||
| add_foreign_key :coplan_comments, :coplan_comment_threads, column: :comment_thread_id | ||
|
|
||
| create_table :coplan_edit_leases, id: { type: :string, limit: 36 } do |t| | ||
| t.string :plan_id, limit: 36, null: false | ||
| t.string :holder_id, limit: 36 | ||
| t.string :holder_type, null: false | ||
| t.string :lease_token_digest, null: false | ||
| t.timestamp :expires_at, null: false | ||
| t.timestamp :last_heartbeat_at, null: false | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_edit_leases, :plan_id, unique: true | ||
| add_foreign_key :coplan_edit_leases, :coplan_plans, column: :plan_id | ||
|
|
||
| create_table :coplan_edit_sessions, id: { type: :string, limit: 36 } do |t| | ||
| t.string :plan_id, limit: 36, null: false | ||
| t.string :plan_version_id, limit: 36 | ||
| t.string :actor_id, limit: 36 | ||
| t.string :actor_type, null: false | ||
| t.string :status, default: "open", null: false | ||
| t.integer :base_revision, null: false | ||
| t.text :draft_content, size: :long | ||
| t.text :change_summary | ||
| t.json :operations_json, null: false | ||
| t.timestamp :expires_at, null: false | ||
| t.timestamp :committed_at | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_edit_sessions, [:plan_id, :status] | ||
| add_foreign_key :coplan_edit_sessions, :coplan_plans, column: :plan_id | ||
| add_foreign_key :coplan_edit_sessions, :coplan_plan_versions, column: :plan_version_id | ||
|
|
||
| create_table :coplan_api_tokens, id: { type: :string, limit: 36 } do |t| | ||
| t.string :user_id, limit: 36, null: false | ||
| t.string :name, null: false | ||
| t.string :token_digest, null: false | ||
| t.string :token_prefix, limit: 8 | ||
| t.timestamp :expires_at | ||
| t.timestamp :revoked_at | ||
| t.timestamp :last_used_at | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_api_tokens, :user_id | ||
| add_index :coplan_api_tokens, :token_digest, unique: true | ||
| add_foreign_key :coplan_api_tokens, :coplan_users, column: :user_id | ||
|
|
||
| create_table :coplan_automated_plan_reviewers, id: { type: :string, limit: 36 } do |t| | ||
| t.string :key, null: false | ||
| t.string :name, null: false | ||
| t.text :prompt_text, null: false | ||
| t.string :ai_provider, default: "openai", null: false | ||
| t.string :ai_model, null: false | ||
| t.json :trigger_statuses, null: false | ||
| t.boolean :enabled, default: true, null: false | ||
| t.timestamps | ||
| end | ||
|
|
||
| add_index :coplan_automated_plan_reviewers, :key, unique: true | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Automatically copy engine migrations before db:migrate so hosts | ||
| # never silently fall behind on schema changes. | ||
| # Rails derives the task name from CoPlan → co_plan. | ||
| Rake::Task["db:migrate"].enhance(["co_plan:install:migrations"]) if Rake::Task.task_defined?("db:migrate") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the migration-path initializer drops
engine/db/migratefrom the host migration search path, so environments that run onlydb:migrate/db:preparewill silently stop applying future CoPlan schema changes unless they remember an extracoplan:install:migrationsstep every upgrade. In this repo there is no automated install step (only docs mention it), so a later engine migration would leave production/test DBs behind the code and cause runtime failures when new columns/tables are referenced.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add that extra step?