SQL seed data with foreign keys
A seed fails when orders.user_id points at a user that was never inserted. SchemaSeed generates the parent table first and copies those ids into the child table. The SQL file is written in the same order, so a foreign key constraint can succeed.
Paste both tables
CREATE TABLE users ( id INTEGER PRIMARY KEY, email VARCHAR(255) NOT NULL ); CREATE TABLE orders ( id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id), total DECIMAL(10, 2) );
Users are filled first. Each user_id is one of those user ids, not a random integer. The download inserts users, then orders.
What you can generate
Every table is generated, up to 10,000 rows. Foreign keys are taken from the parent rows. There is no account.
JSON and CSV export the table you are looking at. SQL export writes every generated table into schemaseed.sql.