I'm trying to create a table on activation, and add a foreign key to it - but I keep getting a Fatal Error with a generic 'This table already exists...' message.
I'm using basic code, below, can anybody point me in the right direction of how to create database tables with Herbert and assign Foreign Keys?
/**
* Create
*
* This method creates the table.
*
* @return void
*/
private function _create()
{
Capsule::schema()->create($this->tableName, function ($table) {
$table->increments('id');
$table->integer('postId')->unsigned();
$table->text('fullPicture')->nullable();
$table->text('picture')->nullable();
$table->string('description')->nullable();
$table->string('caption')->nullable();
$table->string('permalinkUrl')->nullable();;
$table->timestamps();
$table->softDeletes();
});
Capsule::schema()->table($this->tableName, function($table) {
$table->foreign('postId')->references('id')->on('wp01_users');
});
}
Hi,
I'm trying to create a table on activation, and add a foreign key to it - but I keep getting a Fatal Error with a generic 'This table already exists...' message.
I'm using basic code, below, can anybody point me in the right direction of how to create database tables with Herbert and assign Foreign Keys?