i have Category model, and i want to use it for posts and topics. and i think should use many to many ploymorphic relation, but in migrating i get this error:
Illuminate\Database\QueryException : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forum.categoriables' doesn't ex
ist (SQL: alter table `categoriables` add `category_id` int unsigned not null, add `categoriable_id` int unsigned not null, add `ca
tegoriable_type` varchar(191) not null)
this is categories table:
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('slug')->unique();
$table->unsignedInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->unsignedInteger('parent_id');
$table->foreign('parent_id')->references('id')->on('topics')->onDelete('cascade');
$table->timestamps();
});
and this is categoriables table:
Schema::table('categoriables', function (Blueprint $table) {
$table->unsignedInteger('category_id');
$table->unsignedInteger('categoriable_id');
$table->string('categoriable_type');
});
each of them are in separate migration file.