Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions app/admin/folders.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ActiveAdmin.register CoPlan::Folder, as: "Folder" do
permit_params :name, :parent_id, :created_by_user_id

index do
selectable_column
id_column
column :name
column("Path") { |folder| folder.path }
column :parent
column :created_by_user
column :created_at
actions
end

show do
attributes_table do
row :id
row :name
row("Path") { resource.path }
row :parent
row :created_by_user
row :created_at
row :updated_at
end

panel "Subfolders" do
table_for resource.children.order(:name) do
column :id
column :name
column :created_at
end
end

panel "Plans" do
table_for resource.plans.order(updated_at: :desc) do
column :id
column :title
column :status
column :updated_at
end
end
end

form do |f|
f.inputs do
f.input :name
f.input :parent, collection: CoPlan::Folder.order(:name).map { |folder| [folder.path, folder.id] }
f.input :created_by_user, collection: CoPlan::User.order(:name).map { |u| [u.name, u.id] }
end
f.actions
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This migration comes from co_plan (originally 20260602170000)
class DropCoplanAutomatedPlanReviewers < ActiveRecord::Migration[8.0]
def up
drop_table :coplan_automated_plan_reviewers
end

def down
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
24 changes: 24 additions & 0 deletions db/migrate/20260716154625_create_coplan_folders.co_plan.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This migration comes from co_plan (originally 20260716000000)
class CreateCoplanFolders < ActiveRecord::Migration[8.1]
def change
create_table :coplan_folders, id: { type: :string, limit: 36 } do |t|
t.string :name, null: false
t.string :parent_id, limit: 36
t.string :created_by_user_id, limit: 36
t.timestamps

# Unique per sibling group. MySQL treats NULLs as distinct in unique
# indexes, so root-level (parent_id IS NULL) uniqueness is enforced by
# the model validation instead — same approach either way for app code.
t.index [:parent_id, :name], unique: true
t.index :created_by_user_id
end

add_column :coplan_plans, :folder_id, :string, limit: 36
add_index :coplan_plans, :folder_id

add_foreign_key :coplan_folders, :coplan_folders, column: :parent_id
add_foreign_key :coplan_folders, :coplan_users, column: :created_by_user_id
add_foreign_key :coplan_plans, :coplan_folders, column: :folder_id
end
end
17 changes: 16 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,14 @@
q3 = CoPlan::Plan.find_by(title: "Q3 Product Roadmap")
q3.tag_names = ["roadmap", "product"] if q3 && q3.tags.empty?

puts "Done! #{CoPlan::User.count} users, #{CoPlan::Plan.count} plans, #{CoPlan::CommentThread.count} threads, #{CoPlan::Comment.count} comments, #{CoPlan::ApiToken.count} API tokens."
puts "Seeding folders..."
if CoPlan::Folder.count == 0
product = CoPlan::Folder.find_or_create_by_path!("Product/Q3", created_by_user: hampton)
infra = CoPlan::Folder.find_or_create_by_path!("Infrastructure", created_by_user: hampton)

q3&.update!(folder: product) if q3&.folder_id.nil?
api_seed = CoPlan::Plan.find_by(title: "API Rate Limiting Strategy")
api_seed&.update!(folder: infra) if api_seed&.folder_id.nil?
end

puts "Done! #{CoPlan::User.count} users, #{CoPlan::Plan.count} plans, #{CoPlan::Folder.count} folders, #{CoPlan::CommentThread.count} threads, #{CoPlan::Comment.count} comments, #{CoPlan::ApiToken.count} API tokens."
Loading
Loading