I want to add some new columns in my existing table users in laravel.
I have already googling for that and following those search I have already created migration using the command php artisan make:migration add_columns_to_users.
add_columns_to_users.php
public function up()
{
Schema::table('users', function($table) {
$table->string('address');
$table->string('city');
$table->string('tribe');
$table->string('country');
$table->integer('student_id');
$table->string('tribe_university_name');
$table->string('student_program_of_study');
$table->string('faculty');
$table->string('level');
});
}
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('address');
$table->dropColumn('city');
$table->dropColumn('tribe');
$table->dropColumn('country');
$table->dropColumn('student_id');
$table->dropColumn('tribe_university_name');
$table->dropColumn('faculty');
$table->dropColumn('level');
});
}
After creation, I run this command php artisan migrate.
But got the same error:
Base table or view already exists: 1050 Table 'users' already exists (SQL: create table
users(idint unsigned not null auto_increment primary key,namevarchar(255) not null,passwordvarchar(255) not null,remember_tokenvarchar(100) null,created_attimestamp null,updated_attimestamp null) default character set utf8 collate utf8_unicode_ci)
Full name of user table 2014_10_12_000000_create_users_table.php and the other name is 2019_04_11_074552_add_column_to_users.php
How to solve this?
My main query is How to add new columns in my existing table?
addColumnToUser. - Zakaria AcharkiAddColumnToUsers- Arafat Rahman