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 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}
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 the table is not empty, the framework intercepts the insert, logs a warning, and safely skips the remainder of that specific seeder file.
this behavior ensures that you can safely rerun your entire seeder suite multiple times without risking duplicate data or primary key collisions on established tables.

