我在迁移文件up
2016_07_08_121013_drop_templates_table.php
方法
public function up()
{
Schema::drop('templates');
}
我必须在down()
方法中重新创建模板表。有没有办法我不必重复自己?比如从其他创建模板表的迁移中执行up
方法?
答案 0 :(得分:0)
你可以这样做:
private function createTable(){
Schema::create('table', function( ....
//the table schema
);
}
然后按照您的up
或down
方法调用它:
$this->createTable();
你可以将该方法设为公开,然后将其调用到另一个文件中,如果这是您要查找的内容