For example, I have three migration tables(e.g. User, Role, Department) that I need to migrate. In laravel, it is as simple as issuing the command:
php artisan migrate
However, I'm using Windows(cmd/powershell), and every time I issue the migrate command only the first table gets migrated. If I try to re-issue the migrate command I get an error stating the "Users table exists".
Do I have an error in my laravel installation or is this normal?
In order to bypass the above error, I have to rename each table.For example, if I migrated "User", then I need to rename the User table as:
"create_users_table_2344747474.sql.bak"
The above is necessary for me in order to facilitate the migration of the other tables, in this example "Role" and "Department" as explained above.
Update: specific error. Description: as you can see below, the "User table" is migrated successfully. I can see it in mysql. However, the other tables are not migrated. Laravel is Laravel Framework 5.6.13
Update: user table migration.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
These other migrations are not "migrated" to the database.
What is your version of mysql? as per documentation: If you are running a version of MySQL older than the 5.7.7 release or MariaDB older than the 10.2.2 release, you may need to manually configure the default string length generated by migrations in order for MySQL to create indexes for them. You may configure this by calling the Schema::defaultStringLength method within your AppServiceProvider:
use Illuminate\Support\Facades\Schema;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}