Question: i'm learning and trying to use laravel 5.2, i'm confusing how to add field in a table. 

I create a migration file called 2016\_01\_29\_093417\_create\_thread\_table.php, everytime i want to add a field, i add a code inside the file e.g 

```
$table->string('content');  

```

and then run the command 

```
php artisan migrate:refresh

```

the new field will appear in the table but the testing data (e.g a user in user table will be truncated)

The questions are:

1) what is the right way (best practice) to add new field to a table?
2) how to keep the testing data all the tables, e.g user in users table?

Anyone know how to do?

Answer: 
There are two ways to do this.

**Your application is already live** with people using it and you don't want to lose their data: you simply make a new migration and supply `up()` and `down()` with corresponding operations. For example:

```
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class UsersNewField extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function ($table) {
            $table->string('email');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function ($table) {
            $table->dropColumn('email');
        });
    }
}

```

After you run `php artisan migrate` it will simply run the latest migration.

**Your application is still in development** and nobody is using it yet: you use seeds to populate your database with testing data and edit your initial migration as necessary. For example:

```
<?php

use Illuminate\Database\Seeder;

class UsersSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('users')->insert([
            'name' => 'First User',
            'email' => 'user1@example.com',
            'password' => bcrypt('somepass9019'),
        ]);

        DB::table('users')->insert([
            'name' => 'Second User',
            'email' => 'user2@example.com',
            'password' => bcrypt('somepass2039'),
        ]);

        DB::table('users')->insert([
            'name' => 'Third User',
            'email' => 'user3@example.com',
            'password' => bcrypt('somepass0534'),
        ]);
    }
}

```

After you run `php artisan migrate:refresh --seed` it will reset the database and seed it with initial/testing data.
well you need to create a new migration for each column changes 

you need to use `migrate`

`migration:refresh` will reset and seed the database again

I would suggest make use of seeders and model factories if you wish to preserve your testing data and save time entering data again
<https://laravel.com/docs/5.1/seeding#using-model-factories>