所以,我创建了一个新的包,位于 vendor/vendorname/package
我已将新包添加到我的 app/config/app.php
中文件的提供者数组:
'Seriousjelly\Portfolio\PortfolioServiceProvider'
我的包composer.json文件似乎合法:
"autoload": {
"classmap": [
"src/migrations",
"src/controllers",
"src/models",
"src/repositories"
],
"psr-0": {
"Seriousjelly\\Portfolio\\": "src/"
}
在 seriousjelly/porfolio/src/migrations
我有 2 次迁移:
2014_06_25_060429_create_portfolio_categories_table.php:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePortfolioCategoriesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('portfolio_categories', function(Blueprint $table){
$table->increments('id');
$table->string('title', 255);
$table->string('subtitle', 255);
$table->string('short_description', 500);
$table->string('description');
$table->string('slug', 60);
$table->timestamp();
});
Schema::create('portfolio_item_categories', function(Blueprint $table) {
$table->integer('category_id')->unsigned();
$table->foreign('category_id')->references('id')->on('portfolio_categories');
$table->integer('item_id')->unsigned();
$table->foreign('item_id')->references('id')->on('portfolio_items');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('portfolio_categories');
Schema::drop('portfolio_item_categories');
}
}
和2014_06_25_060414_create_portfolio_items_table.php:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePortfolioItemsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('portfolio_items', function(Blueprint $table) {
$table->increments('id');
$table->string('title', 255);
$table->string('subtitle', 255)->nullable;
$table->string('short_description', 500)->nullable;
$table->string('description', 500);
$table->string('slug', 60);
$table->timestamp();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('portfolio_items');
}
}
现在,当我运行 php artisan migrate --package=seriousjelly/portfolio
时
它显示迁移已成功运行,但是,如果我检查数据库,则仅填充了迁移表。
如果我再次运行该命令,什么也不会发生,没有错误,没有消息,什么也没有。
有什么想法吗?
p.s 其他包迁移是相同的并且似乎运行正常,我尝试过 Composer update 和 Composer dump-autoload 但这不起作用。
最佳答案
啊,好吧,我的错。看来我拼写错误,原来是复数:
$table->timestamps();
我不确定为什么终端从未抛出错误......
关于php - 包迁移不起作用(没有错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24401893/