Skip to content

Consolidate dev payment seeds into db:seed:dev#1573

Merged
maebeale merged 3 commits into
mainfrom
maebeale/consolidate-payment-seeds
Jun 6, 2026
Merged

Consolidate dev payment seeds into db:seed:dev#1573
maebeale merged 3 commits into
mainfrom
maebeale/consolidate-payment-seeds

Conversation

@maebeale

@maebeale maebeale commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

What is the goal of this PR and why is this important?

  • db/seeds.rb should only contain seeds required to stand up a new build — never fake/test data. It runs on every db:seed, including production, so it must hold only the genuinely-required base data (users, form builders, category types, etc.).
  • Payment seed data (test people, a sample "Test Payments Workshop" event, and payment/allocation/refund scenarios) was being loaded from db/seeds.rb, so it ran in production too. That's sample data for exercising the payments UI, not required base data, so seeding "Bob Barker" payments in production was wrong.
  • We use db:seed:dev to handle all fake/sample data for local development; this PR moves payment seeds there and tidies up how dev seeds are organized.

How did you approach the change?

  • Moved dev-only seeds under db/seeds/dev/ so the directory itself signals "never runs in production" (dummy_dev_seeds.rbdev/dummy.rb, payments.rbdev/payments.rb).
  • Split dev seeding into focused rake tasks, each runnable on its own:
    • db:seed:dummy — generic dummy dev data
    • db:seed:payments — sample payments/allocations/refunds
    • db:seed:dev — orchestrates db:seeddb:seed:dummydb:seed:payments
  • Removed the seed "payments" call (and the now-unused seed helper) from db/seeds.rb, so the base/production seed run no longer creates payment sample data.
  • Renamed the dev task db:dev:seeddb:seed:dev to sit alongside Rails' built-in db:seed:replant (variations of seeding under the db:seed:* namespace).
  • Consolidated all payment seeding into dev/payments.rb: the Scholarships/Payments/Allocations block that lived in the dummy seeds (added by Add per-event dashboard with drill-in registrant filters #1565 to give the event-overview dashboard real numbers) now lives in dev/payments.rb. It re-resolves the events/people/registrations it funds via find_by (still created in dev/dummy.rb, which db:seed:dev runs first). Event cost_cents, the scholarship application form, and registration scholarship flags stay in dev/dummy.rb — they're event/registration setup, not payment records.

UI Testing Checklist

  • No UI changes — seed/rake refactor only.

Anything else to add?

  • Verified with rake db:seed:payments: the event-overview dashboards report the expected received/outstanding/scholarship totals after the move.
  • Follow-up planned: split db/seeds/dev/dummy.rb into individual named files under db/seeds/dev/, and have db:seed:dummy glob the directory.

Copilot AI review requested due to automatic review settings June 6, 2026 19:44
@maebeale maebeale marked this pull request as ready for review June 6, 2026 19:44
Comment thread lib/tasks/dev.rake
load Rails.root.join("db/seeds/dummy_dev_seeds.rb")
namespace :seed do
desc "Generate representative sample data for development"
task dev: [ :environment, "db:seed", "db:seed:dummy", "db:seed:payments" ]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Used prerequisite ordering (db:seeddummypayments) instead of Rake::Task[...].invoke in a body — prereqs run in listed order and are deduped. Each subtask is independently runnable.

Comment thread lib/tasks/dev.rake
task dev: [ :environment, "db:seed", "db:seed:dummy", "db:seed:payments" ]

desc "Seed generic dummy dev data (workshops, people, stories, etc.)"
task dummy: :environment do

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Dev seeds now live under db/seeds/dev/ so the path itself flags them as never-run-in-production. Renamed dummy_dev_seeds.rbdev/dummy.rb to drop the redundant dev.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR moves development-only payment/sample seed data out of the base db:seed path (so it won’t run in production) and consolidates dev seeding behind a db:seed:dev task.

Changes:

  • Added db:seed:dev, db:seed:dummy, and db:seed:payments rake tasks and moved dev seeds under db/seeds/dev/.
  • Removed the payments seed hook (and helper) from db/seeds.rb so production seeding no longer creates sample payment data.
  • Updated contributor docs to reference the new db:seed:dev task.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/tasks/dev.rake Introduces the new db:seed:* tasks and loads the new dev seed scripts.
db/seeds/dev/payments.rb Updates header docs to point to the new dev-only task locations.
db/seeds/dev/dummy.rb Adds the consolidated dev-only dummy dataset used by the new tasks.
db/seeds.rb Removes payments seeding from the base seed run.
CONTRIBUTING.md Updates dev seed instructions to rake db:seed:dev.

Comment thread lib/tasks/dev.rake
Comment on lines +6 to +9
desc "Seed generic dummy dev data (workshops, people, stories, etc.)"
task dummy: :environment do
load Rails.root.join("db/seeds/dev/dummy.rb")
end

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Intentional — db:seed is a prerequisite of db:seed:dev, not the granular tasks, so a dev can re-run dev data without a full base reseed every time. The granular tasks assume base data is already present. On mail: dev uses delivery_method = :file + raise_delivery_errors = false, and these seeds invoke no mailer (Notification has no send callback; no users are created here), so nothing is delivered.

Comment thread lib/tasks/dev.rake
Comment on lines +11 to 14
desc "Seed sample payments, allocations, and refunds (dev only)"
task payments: :environment do
load Rails.root.join("db/seeds/dev/payments.rb")
end

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Same as the dummy task — the db:seed dependency lives on db:seed:dev by design (fast iteration), and payments.rb is self-contained (creates its own people/event), so it needs no base data. No mailers are triggered and dev delivery is :file, so no emails go out.

@maebeale maebeale requested a review from jmilljr24 June 6, 2026 19:51
maebeale and others added 2 commits June 6, 2026 15:59
Payment seed data (test people, a sample event, and payment/allocation/
refund scenarios) was loaded from the base db/seeds.rb, so it ran on every
db:seed — including production. It is sample data for exercising the
payments UI, not required base data, so it does not belong in the
production seed run.

- Move dev-only seeds under db/seeds/dev/ to signal they never run in prod
- Split seeding into rake tasks: db:seed:dummy and db:seed:payments, both
  orchestrated by db:seed:dev (which still runs the base db:seed first)
- Drop the payment seed call (and now-unused seed helper) from db/seeds.rb
- Rename the dev task db:dev:seed -> db:seed:dev to sit alongside the
  built-in db:seed:replant

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rake db:seed:payments already runs the file on its own, so the prior
'can also be run independently' wording was confusing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale force-pushed the maebeale/consolidate-payment-seeds branch from 73835c2 to 3232754 Compare June 6, 2026 19:59
PR #1565 (merged to main) added a Scholarships/Payments/Allocations
section to the dummy dev seeds to give the event-overview dashboard real
numbers. With dev/payments.rb now the single home for payment sample
data, keeping payment-record creation in dummy split that concern across
two files.

- Move the scholarship/payment/allocation funding (CashPayment,
  CheckPayment, Allocation, Scholarship) out of dummy.rb into payments.rb,
  re-resolving the events/people/registrations it funds via find_by since
  those are still created in dummy.rb (run first by db:seed:dev)
- The funding guards on missing events, so db:seed:payments on its own is
  a no-op for dummy events and only funds them as part of db:seed:dev
- Event cost_cents, the scholarship application form, and registration
  scholarship flags stay in dummy.rb — they're event/registration setup,
  not payment records
- Normalize payments.rb's leftover global indentation to top level

Verified via `rake db:seed:payments`: dashboards report the expected
received/outstanding/scholarship totals.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 6, 2026 20:07
Comment thread db/seeds/dev/payments.rb
a.created_at = 3.days.ago
end

puts "Creating Scholarships, Payments, and Allocations for dev events…"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Moved here from dev/dummy.rb (added by #1565) so all payment seeding lives in one file. It funds dummy-created registrations via find_by, so it only does anything when run after db:seed:dummy (which db:seed:dev guarantees); standalone db:seed:payments safely no-ops these via the fund_registration guards.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread db/seeds/dev/payments.rb
Comment on lines +6 to +14
payment_ids_start = Payment.maximum(:id) || 0
allocation_ids_start = Allocation.maximum(:id) || 0
refund_ids_start = Refund.maximum(:id) || 0
event_reg_ids_start = EventRegistration.maximum(:id) || 0

Refund.where("id > ?", refund_ids_start).delete_all
Allocation.where("id > ?", allocation_ids_start).delete_all
Payment.where("id > ?", payment_ids_start).delete_all
EventRegistration.where("id > ?", event_reg_ids_start).delete_all
Comment thread db/seeds/dev/payments.rb
reg_gary = EventRegistration.find_or_create_by!(registrant: gary, event: event)
reg_iris = EventRegistration.find_or_create_by!(registrant: iris, event: event)

puts " Payment made but allocation reverted)"

@jmilljr24 jmilljr24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The comments about seeds.rb being needed for production seems inaccurate but I think is irrelevant. My understanding from our conversation is seeds.rb is base data needing for development and the dev seeds are if you want the extra goodies.

@maebeale maebeale merged commit f81b949 into main Jun 6, 2026
4 checks passed
@maebeale maebeale deleted the maebeale/consolidate-payment-seeds branch June 6, 2026 21:00
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.

3 participants