laravel migration insert data code example
Example 1: add column in laravel migration
php artisan make:migration add_paid_to_users_table --table=users
Example 2: insert rows in migrations laravel
public function up()
{
Schema::create('users', function($table){
$table->increments('id');
$table->string('email', 255);
$table->string('password', 64);
$table->boolean('verified');
$table->string('token', 255);
$table->timestamps();
});
DB::table('users')->insert(
array(
'email' => '[email protected]',
'verified' => true
)
);
}
Example 3: add new column in existing table in laravel migration
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('paid');
});
}
Example 4: Generate Laravel Migrations from an existing database
composer require --dev "xethron/migrations-generator"