I cant figure out what the problem is, the 2 tables are not connecting for some reason, I read many articles and tried many things still not working.
I want to link post and category tables together, so when I can display the category chosen in the post made.
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('name');
$table->text('description');
$table->integer('category_id');
$table->integer('price');
$table->integer('currency_id');
});
}
Category
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('name');
$table->bigInteger('post_id')->unsigned();
$table->foreign('post_id')->references('id')->on('posts');
});
}
This is the error I get:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'categories' already exists (SQL: create table
categories(idbigint unsigned not null auto_increment primary key,created_attimestamp null,updated_attimestamp null,namevarchar(255) not null,post_idbigint unsigned not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')