On this page
seeding
introduction
seeding allows you to populate your newly migrated database tables with initial or dummy data, completing the setup process for new environments instantly. dframework provides a simple mechanism for defining and executing these seeding operations.
writing seeders
seeder files live in the database/seeders/ directory and are responsible for populating tables with data. similar to migrations, a seeder file must export an asynchronous run function. the framework injects a context object containing the fluent table query builder, giving you direct access to insert operations.
these context properties are also available globally during execution.
1export async function run({ table }) {2 await table('users').insert([3 {4 name: 'admin',5 email: 'admin@example.com',6 password: 'password' // automatically hashed7 }8 ]);9}
running seeders
to execute all available seeders in sequence, execute the seed command:
1dstrn seed
to run a specific individual seeder, pass the seeder name as an argument:
1dstrn seed UserSeeder2dstrn seed 001_UserSeeder
when executing in production (APP_ENV=production), the seed command prompts for confirmation to prevent accidental data changes. use the --force flag for automated provisioning pipelines:
1dstrn seed --force
automatic safety checks
the seeder runner is designed for safety in production environments.
before executing an insert statement within a seeder, the framework performs a database count on the target table. if records exist, the runner rolls back the transaction for that seeder and skips the entire seeder file, allowing seeder suites to run repeatedly without primary key collisions or duplicate rows.

