laravel 使用artisan命令新增数据库字段
2017-09-12 09:54
357 查看
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
由百牛信息技术bainiu.ltd提供
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
由百牛信息技术bainiu.ltd提供
相关文章推荐
- laravel 使用artisan命令新增数据库字段
- laravel 使用artisan命令新增数据库字段
- Laravel 使用artisan命令 创建数据库表,实体类和controller
- 数据库Postgresql在使用Hibernate自动新增字段后插入不生效
- Laravel 下 artisan 命令工具使用
- Laravel基础(四)--使用Eloquent ORM操作数据库之新增记录
- laravel中artisan工具(命令)的使用详解
- laravel 新增数据库字段
- Laravel在Mac下使用php artisan migrate命令出现No such file or directory
- 使用sdeexport和sdeimport命令对SDE数据库的备份、迁移或恢复
- 使用 sapdba 命令来管理数据库
- 使用 sapdba 命令来管理数据库
- 使用expdp命令备份Oracle 10g数据库【转】
- 使用JDBC读取和插入XMLTYPE类型的数据库字段
- 为 Analysis Services 数据库使用扩展字段属性(SQL Server 2005 联机丛书(2008 年 11 月))
- 数据库中的字段为空时,使用isnull函数
- 今天写了一个使用TreeView显示年-月-日-数据的四级格式(数据库表只有一个日期字段)
- 在Hibernate中使用数据库字段默认值的配置
- 地磅称量系统之(37~39) 直接向数据库的数据表WtBill添加测试数据以及绑定用户控件和使用编码的方式控制dataGridView控件的每列属性和添加数据数据库的表中不存在的字段(非绑定列)
- 数据库中的字段为空时,使用isnull函数