I need to create a relevant amount of tables and checking the Laravel 4 documentation I see the following code:
Schema::create('users', function($table)
{
$table->increments('id');
});
I assume that in one migration file, I can create as many tables as I want using the code above. Is this assumption right? Is it a bad practice?
Yes, migrations can do multiple DB modifications (add tables, drop tables, add indexes, etc).
It is not considered bad form. A migration is a collection of steps necessary to upgrade/downgrade your database to the next/previous format, respectively
Schema::create('users', function($table)
{
$table->increments('id');
});
Schema::create('rights', function($table)
{
$table->increments('id');
});
In our case, migrations are tied to our ticket system. When a feature or bug is to be deployed, the appropriate migration is deployed with it. Sometimes we add columns, new tables, or drop stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With