laravel 使用artisan命令新增数据库字段

来源:互联网 发布:软装设计软件 编辑:程序博客网 时间:2024/05/16 15:02

cmd 命令行 到项目目录,不是public那个目录

D:\Program Files\wamp\www\Book>php artisan migrate:make add_machine_type_to_booksCreated Migration: 2013_09_05_104157_add_machine_type_to_booksGenerating optimized class loader

migrations目录下面就会生成一个文件,在里面修改即可

文档可见:http://v3.golaravel.com/docs/database/schema.html

<?phpuse Illuminate\Database\Migrations\Migration;class AddMachineTypeToBooks extends Migration {/** * Run the migrations. * * @return void */public function up(){Schema::table('books',function($table){$table->integer('machine_type');$table->string('lan_ip',100);$table->string('remote_ip',100);});}/** * Reverse the migrations. * * @return void */public function down(){Schema::table('books',function($table){$table->drop_column('machine_type');$table->drop_column('lan_ip');$table->drop_column('remote_ip');});}}


分别执行如下,就可以了

php artisan migrate:refreshphp artisan db:seed



原创粉丝点击