Add New Column Seeder

Submitted by faizalpribadi - 2 years ago

Add New Colum To Exist Table With Seeder

class AddColumnSeeder extends Seeder
{
    public function run()
    {
        DB::table('test')->delete();

        Schema::table('test', function(\Illuminate\Database\Schema\Blueprint $table) {
            $table->string('add')->after('exist_column_name');
            $table->boolean('confirmed')->default(0);
        });
    }
}

class DatabaseSeeder extends Seeder {

    /**
	 * Run the database seeds.
	 *
	 * @return void
	 */
	public function run()
	{
		Eloquent::unguard();

		// $this->call('UserTableSeeder');
		$this->call('AddColumnSeeder');
	}

}

# artisan db:seed

Ads cover the costs of maintaining Laravel-tricks

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks