-
Notifications
You must be signed in to change notification settings - Fork 19
Re running Seed Files
Matt Roth edited this page Mar 29, 2023
·
13 revisions
Some seed files located in db/seeds can be manually run from the rails console to generate more data for testing. Listed below are instructions to manually run these seeds, as well as which seed files can and cannot be run.
In some rare cases, running a seed file can generate an ActiveRecord::RecordNotUnique: PG::UniqueViolation error. This is generally due to the way some objects are created in the seed files; most objects related to the service fakes are created from the Generators in lib/generators, while objects being persisted in the DBs are created with FactoryBot using the factories in spec/factories. The generators are set up to assign random values to their IDs, which can cause data collisions during seeding.
- Open a rails console (make c)
- Run the following commands:
- RequestStore[:current_user] = User.system_user
- Dir[Rails.root.join("db/seeds/*.rb")].sort.each { |f| require f }
- For the desired seed file, run the following command:
- Seeds::{Seed_File_Name}.new.seed!
- Run the following command
bundle exec rails runner scripts/run_seed_data_file.rb db/seeds/_______.rb
- Tasks
- Hearings
- Jobs
- Substitutions
- DecisionIssues
- CavcAmaAppeals
- MTV
- PriorityDistributions
- Tasks
- create_legacy_appeals_with_open_schedule_hearing_task will not add new legacy appeals
- create_colocated_legacy_tasks will not add new tasks
- create_legacy_appeal_at_acting_judge will not create new legacy appeals
- create_legacy_issues_eligible_for_opt_in will not create new legacy issues or appeals
- Annotations
- Tags
- Intake
- This can be run again, but may error multiple times due to contention_reference_id uniqueness, which is caused by the VBMS service fakes
- SanitizedJsonSeeds
- Users
- Dispatch
- VeteransHealthAdministration
- Education
- Home
- Acronyms and Glossary
- Caseflow products
- Caseflow Intake
- Caseflow Queue
- Appeals Consumer
- Caseflow Reader
- Caseflow eFolder
- Caseflow Hearings
- Caseflow Certification
- Caseflow APIs
- Appeal Status API
- Caseflow Dispatch
-
CSUM Roles
- System Admin
- VHA Team Management
- Active Record Queries Resource
- External Integrations
- Caseflow Demo
- Caseflow ProdTest
- Background
- Stuck Jobs
- VA Notify
-
Caseflow-Team
- Tier 4
- Bat Team
- Technical Documentation
- Backend Code Patterns
- Backend Working Group
- FACOLS, VACOLS DB Schema
- Asyncable Models
- External Data: where and why
- Data Fetching Scripts
- Caseflow Data Model and Dictionary
- User Access Permissions
- Controller Schemas
- Constants
- Frontend Best Practices
- Accessibility
- How-To
- Debugging Tips
- Adding a Feature Flag with FeatureToggle
- Editing AMA issues
- Editing a decision review
- Fixing task trees
- Investigating and diagnosing issues
- Data and Metric Request Workflow
- Exporting and Importing Appeals
- Explain page for Appeals
- Record associations and Foreign Keys
- Upgrading Ruby
- Stuck Appeals
- Testing Action Mailer Messages Locally
- Re-running Seed Files
- Rake Generator for Legacy Appeals
- Manually running Scheduled Jobs
- System Admin UI
- Caseflow Makefile
- Upgrading Postgresql from v11.7 to v14.8 Locally
- VACOLS VM Trigger Fix M1
- Using SlackService to Send a Job Alert
- Technical Talks