Am luat un pachet, nu pot rula migratiile, sunt 2 migratii. Prima pare sa fie ok, a2-a nu.
Eroare:
Prima migratie:
public function up()
{
$tableName = 'comments';
Schema::create($tableName, function (Blueprint $table) use ($tableName) {
$table->increments('id');
$table->unsignedInteger('commentable_id')->nullable();
$table->string('commentable_type')->nullable();
$table->index(['commentable_id', 'commentable_type']);
$table->string('page_id')->index()->nullable();
$table->integer('user_id')->unsigned()->nullable();
$table->string('author_name')->nullable();
$table->string('author_email')->nullable();
$table->string('author_url')->nullable();
$table->string('author_ip')->nullable();
$table->string('user_agent')->nullable();
$table->text('content');
$table->string('permalink')->nullable();
$table->integer('upvotes')->default(0);
$table->integer('downvotes')->default(0);
$table->enum('status', ['approved', 'pending', 'spam', 'trash'])->default('approved');
$table->integer('root_id')->unsigned()->index()->nullable();
$table->integer('parent_id')->unsigned()->index()->nullable();
$table->timestamps();
$table->foreign('root_id')
->references('id')
->on($tableName)
->onDelete('cascade');
$table->foreign('parent_id')
->references('id')
->on($tableName)
->onDelete('cascade');
});
}
A2-a:
public function up()
{
Schema::create('comment_votes', function (Blueprint $table) {
$table->increments('id');
$table->integer('comment_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->enum('type', ['up', 'down'])->default('up');
$table->timestamps();
$table->foreign('comment_id')
->references('id')
->on('comments')
->onDelete('cascade');
$table->foreign('user_id')
->references('id')
->on((new Comment::$userModel)->getTable())
->onDelete('cascade');
});
}