mrdreamcoin's avatar

Production Seeding Best Practice

I'm creating an app with a songs table that has over 1,000 rows. Each of these rows will be manually created and stored as a schema. I've been using an Eloquent seeder class to seed my development db via artisan. Would you recommend using the same method to populate the production db? Or, should I manually create the songs table in a schema.sql and import that separately from artisan? My concern is that if I create this schema in an Eloquent seeder class, I'll limit the transferability of this schema; whereas creating a standard schema.sql would allow me to reuse the song data wherever, whenever.

Any suggestions?

0 likes
2 replies
mrdreamcoin's avatar

Jeffrey, what would you use instead? Would you recommend using a separate schema.sql? In that case, would you still make the table via artisan migrations and then import the sql via a program like Sequel Pro? Or should I include table creation in the manually run schema? I'm fairly new to populating production tables, so I apologize if I'm not making much sense.

How about this: first, I create a migration for the table. Then, I create a schema.sql that includes the create table command and inserts each row. I run php artisan migrate, which creates the table. I then manually import schema.sql into Sequel Pro. I ignore the error that the songs table already exists, and it populates the table. This way, I have a stand-alone schema.sql that can be used in other environments, and I can still use migrations.

Does this sound like a good idea?

Please or to participate in this conversation.