Consolidate dev payment seeds into db:seed:dev#1573
Conversation
| 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" ] |
There was a problem hiding this comment.
🤖 From Claude: Used prerequisite ordering (db:seed → dummy → payments) instead of Rake::Task[...].invoke in a body — prereqs run in listed order and are deduped. Each subtask is independently runnable.
| 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 |
There was a problem hiding this comment.
🤖 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.rb → dev/dummy.rb to drop the redundant dev.
There was a problem hiding this comment.
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, anddb:seed:paymentsrake tasks and moved dev seeds underdb/seeds/dev/. - Removed the payments seed hook (and helper) from
db/seeds.rbso production seeding no longer creates sample payment data. - Updated contributor docs to reference the new
db:seed:devtask.
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. |
| desc "Seed generic dummy dev data (workshops, people, stories, etc.)" | ||
| task dummy: :environment do | ||
| load Rails.root.join("db/seeds/dev/dummy.rb") | ||
| end |
There was a problem hiding this comment.
🤖 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.
| desc "Seed sample payments, allocations, and refunds (dev only)" | ||
| task payments: :environment do | ||
| load Rails.root.join("db/seeds/dev/payments.rb") | ||
| end |
There was a problem hiding this comment.
🤖 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.
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>
73835c2 to
3232754
Compare
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>
| a.created_at = 3.days.ago | ||
| end | ||
|
|
||
| puts "Creating Scholarships, Payments, and Allocations for dev events…" |
There was a problem hiding this comment.
🤖 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.
| 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 |
| 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
left a comment
There was a problem hiding this comment.
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.
What is the goal of this PR and why is this important?
db/seeds.rbshould only contain seeds required to stand up a new build — never fake/test data. It runs on everydb:seed, including production, so it must hold only the genuinely-required base data (users, form builders, category types, etc.).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.db:seed:devto 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?
db/seeds/dev/so the directory itself signals "never runs in production" (dummy_dev_seeds.rb→dev/dummy.rb,payments.rb→dev/payments.rb).db:seed:dummy— generic dummy dev datadb:seed:payments— sample payments/allocations/refundsdb:seed:dev— orchestratesdb:seed→db:seed:dummy→db:seed:paymentsseed "payments"call (and the now-unusedseedhelper) fromdb/seeds.rb, so the base/production seed run no longer creates payment sample data.db:dev:seed→db:seed:devto sit alongside Rails' built-indb:seed:replant(variations of seeding under thedb:seed:*namespace).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 indev/payments.rb. It re-resolves the events/people/registrations it funds viafind_by(still created indev/dummy.rb, whichdb:seed:devruns first). Eventcost_cents, the scholarship application form, and registration scholarship flags stay indev/dummy.rb— they're event/registration setup, not payment records.UI Testing Checklist
Anything else to add?
rake db:seed:payments: the event-overview dashboards report the expected received/outstanding/scholarship totals after the move.db/seeds/dev/dummy.rbinto individual named files underdb/seeds/dev/, and havedb:seed:dummyglob the directory.