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

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

D:\Program Files\wamp\www\Book>php artisan migrate:make add_machine_typ
e_to_books
Created Migration: 2013_09_05_104157_add_machine_type_to_books
Generating optimized class loader

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

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

<?php

use 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:refresh

php artisan db:seed



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值