laravel mysql版本_Laravel 数据库版本管理系统

database migrations 是laravel最强大的功能之一。数据库迁移可以理解为数据库的版本控制器。

php artisan命令行:

php artisan make:migration

ps:该命令行必须在项目的根目录下执行。

如果对该命令行不是很了解,可是添加参数-h,查看说明文档。

Usage:

make:migration [options] [--] Arguments:

name The name of the migration.

Options:--create[=CREATE] The table to be created.--table[=TABLE] The table to migrate.--path[=PATH] The location wherethe migration file should be created.-h, --help Display thishelp message-q, --quiet Do not output any message-V, --version Display thisapplication version--ansi Force ANSI output--no-ansi Disable ANSI output-n, --no-interaction Do not ask any interactive question--env[=ENV] The environment the command should run under.-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 fordebug

Help:

Create anew migration file

创建数据表

1.直接创建。

php artisan make:migration xxx

这种方式下生成的数据库表类,只有方法,没有初始化数据表的名字已经字段。

classXxx extends Migration

{/**

* Run the migrations.

*

* @return void*/

publicfunction up()

{//}/**

* Reverse the migrations.

*

* @return void*/

publicfunction down()

{//}

}

2.添加参数 --create

php artisan make:migration yyyy --create='yyyy'

这种方式下生成的数据库表类,不仅初始化了数据表的名字,同时添加了默认字段名。

classYyyy extends Migration

{/**

* Run the migrations.

*

* @return void*/

publicfunction up()

{

Schema::create(''yyyy'', function (Blueprint $table) {

$table->increments('id');

$table->timestamps();

});

}/**

* Reverse the migrations.

*

* @return void*/

publicfunction down()

{

Schema::drop(''yyyy'');

}

}

3.添加参数 --table

php artisan make:migration yyyyy --table='yyyyy'

这种方式下生成的数据库表类,已经初始化数据表的名字,但是,没有默认添加字段。

classYyyyy extends Migration

{/**

* Run the migrations.

*

* @return void*/

publicfunction up()

{

Schema::table(''yyyyy'', function (Blueprint $table) {//});

}/**

* Reverse the migrations.

*

* @return void*/

publicfunction down()

{

Schema::table(''yyyyy'', function (Blueprint $table) {//});

}

}

不拒打赏:

5eb48600152a700c7f2e45fe3c9fcb40.png

bad59db23e576ed91aa4926444231a95.png

微信

支付宝

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值