2

This is a question of Seeds vs Migrations (vs any other alternatives there may be!)

Let's say we have a table 'submission_types' of which can not ever be modified by the app itself. For example these types may represent 'video', 'image', 'audio'. This data is necessary for the correct functioning and hypothetical submission of either a video, image or audio file to the site.

Where does the insertion of this data go, as it must be present when the app is running (regardless of dev/production environments)? Should you use Laravel's Seeders? - Seems to me like they are geared towards loading up your database with test data... Or should you use migrations? - Seems that people recommend to keep inserts away from migrations. (Or do you insert the data manually... of course not). To re-iterate, this data must be present under all circumstances and will not be modified by any business logic, ever - this is static data.

This question seems related.

PS: In the future you may want to add some more types to the table, so doing this via migrations seems... less than ideal?

Community
  • 1
  • 1
Titus
  • 720
  • 8
  • 23
  • the link you posted seem to answer your question, seed is the way to go http://laravelbook.com/laravel-database-seeding/ look after the title "Creating New Seed File" how he prepopulate user roles – Amir Bar Dec 16 '15 at 18:30

1 Answers1

0

Your and Mine ways of thinking don't have to agree on what is written above in programming manners!

Perhaps you want to think about this issue after 20 min break, what I'm saying is, bravo for this question but at the same time don't you think you are thinking within the box not out of it?

Simply take those scenarios where:

  • App can't change mandatory values: this means they should be built-in within or part of your app so we are talking config, could be solved with an isolated file that contains your array of mandatory values that possibly be half-dynamic with couple lines of your skills codings.

  • App stores mandatory values upon bootstrapping or in DB like usual:

    In this case you can use seeding to do so, migrations & seedings are built to help you scaffold your app and then fill it, totally okay to use seeding for such purpose EVEN in migration you may do so, and personally I use it with simple admin user I like to create, most likely for testing purposes. but you can do it.

The bottom line is, you are a programmer and your app must have 0 things as mandatory to you. it's your boy and if you are facing mandatory values then there is something wrong IMHO, or you are status quo thinking.

I do respect you, so you please get this in the right way otherwise redirect my understanding to meet yours by explaining more!

Cheers mate!

Community
  • 1
  • 1
Mohamed Kawsara
  • 3,224
  • 2
  • 20
  • 36