Answers for "add row using migration commands in laravel"

PHP
3

insert rows in migrations laravel

public function up()
{
    // Create the table
    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();
    });

    // Insert some stuff
    DB::table('users')->insert(
        array(
            'email' => '[email protected]',
            'verified' => true
        )
    );
}
Posted by: Guest on March-18-2020
1

php artisan add row in table

First, create the file via Artisan (or do it manually if you like):
	php artisan make:migration name_of_the_generated_file --table=table_to_be_added_to
  
Edit the file and add on the 'function up()' so the column will be created once you do 'migrate':
	$table->define_the_type('name_of_the_column')->nullable();
	ps.: 'define_the_type' needs to be changed by the type of field you want to create.
    ps.: 'name_of_the_column' needs to be changed by the name you want the column to have.
  
Then, add on the 'function down()' so we can remove the column with the 'rollback' if needed:
	$table->dropColumn('name_of_the_column');
Posted by: Guest on April-26-2021

Code answers related to "add row using migration commands in laravel"

Browse Popular Code Answers by Language