laravel migration

create table

php artisan make:migration 文件描述 --create=表名

example: php artisan make:migration create_table_notes --create=notes



you can config table filed :

 public function up()
    {
        Schema::create('notes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('gender');
            $table->string('events');
            $table->timestamps();
        });
    }

run : php artisan migrate

caused a error!!!
so you should edit

run again:


you can rollback :

php artisan migrate:rollback

roll back all of your application's migrations:

php artisan migrate:reset 

rename table
Schema::rename($from,$to);

drop table
Schema::drop('users');
Schema::dropIfExists("users");

create Columns
Schema::table("users",function(Blueprint $table){
        $table->string('email');
})

reference:https://laravel.com/docs/5.7/migrations#creating-tables


drop columns
Schema::table('users',function(){
    $table->dropCloumn("name");
});

Reference :https://laravel.com/docs/5.7/migrations

posted @ 2018-12-16 11:21  cyany_blue  阅读(161)  评论(0编辑  收藏  举报