Cayla
0
Q:

laravel migration add column to existing table

php artisan make:migration add_paid_to_users_table --table=users
  
public function up()
{
    Schema::table('users', function($table) {
        $table->integer('paid');
    });
}

public function down()
{
    Schema::table('users', function($table) {
        $table->dropColumn('paid');
    });
}

php artisan migrate
6
php artisan make:migration add_paid_to_users_table --table=users
0
class AddProfileToUsers extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('profile')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('shop_users', function (Blueprint $table) {
            $table->dropColumn(['profile']);
        });
    }
}
1
Schema::table('table_name', function (Blueprint $table) {
            $table->string('column_name', 255)->nullable()->after('previous_column_name');
        });
2
public function down()
{
    Schema::table('users', function($table) {
        $table->dropColumn('paid');
    });
}
1
php artisan make:migration add_profile_to_users
0
php artisan migrate
0
migration add column to existing table in laravel 6 
0

New to Communities?

Join the community