I am using composer for migrating two tables like this:
php artisan make:migration create_two_tables --create="projects","tasks"
Its creating the file in database->migration folder.
but while migrating using
php artisan migrate
its creating only table in database like this:
'projects,tasks'
as one table.
I want only one file and only one command like what I do in the top for migrating two tables in db.
Is there any possibility to get this?
Note: My superior ordered me to not change the database migration file at any cost...
Can anyone help me out here...
The make:migration command is just to create a new migration file from a template. To actually define the migration you normally have to edit that file. So in your case you would do this:
php artisan make:migration create_two_tables --create="projects"
Then open the ***_create_two_tables.php migration file and add the second table:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function(Blueprint $table)
{
});
Schema::create('tasks', function(Blueprint $table)
{
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('projects');
Schema::drop('tasks');
}
Usually you also want to add actual columns to your tables. And that you do inside the Schema::create closure:
Schema::create('projects', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
// and so on
});
Read more about creating tables with the Schema Builder here
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