Reputation: 398
I want to add new column or delete column to a table in laravel migration and I don't want to reset the database because it delete all old data.
Upvotes: 1
Views: 869
Reputation: 1672
make a new migration then the code should be like
Schema::table('users', function (Blueprint $table) {
$table->string('name', 50)->nullable()->change();
});
or if you want to rename
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('from', 'to');
});
or if dropping
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['votes', 'avatar', 'location']);
});
to add simply
Schema::table('users', function (Blueprint $table) {
$table->string('email');
});
Upvotes: 4