建立 Migration
php artisan migrate
// 建立
php artisan make:migration create_users_table --create="users"
// 更新字段
php artisan make:migration alter_tablename_table --table=tablename
// 添加字段
php artisan make:migration add_email_to_users_table --table="users"
更新字段操作
php artisan make:migration alter_tablename_table --table=tablename
Schema::table('admin', function (Blueprint $table) {
//
$table->string('author_name')->default('测试')->change();
});
添加字段
php artisan make:migration add_email_to_users_table --table="users"
Schema::table('users', function(Blueprint $table)
{
$table->string('email', 180)->comment('邮箱');
});
删除字段
php artisan make:migration alter_tablename_table --table=tablename
Schema::table('admin', function (Blueprint $table) {
//
$table->dropColumn('fack','email1');
});
重命名字段
php artisan make:migration alter_tablename_table --table=tablename
相关链接:
https://laravel-china.org/docs/laravel/5.5/migrations/1329#creating-tables
https://docs.golaravel.com/docs/4.1/schema/#renaming-columns
网友评论