Code: Select all
Schema::create('tags', function (Blueprint $table) {
$table->increments('id');
// $table->mediumText('tag');
$table->char('tag' , 15);
});
Code: Select all
public function up()
{
Schema::create('admin', function (Blueprint $table) {
$table->increments('id');
$table->mediumText('title');
$table->text('blog_content');
$table->char('tag' , 15);
$table->string('filePath');
$table->string('slug');
$table->timestamps();
});
Schema::table('admin', function (Blueprint $table) {
$table->foreign('tag')->references('tag')->on('tags');
});
}
Now when i check the laravel docs the examples of foreign keys are all for primary keys:
see here https://laravel.com/docs/5.0/schema#foreign-keys
Does a foreign key always need to be a primary key ??
The tables i have created are of type "InnoDB" .. i get the following error:
http://i.imgur.com/aRaln7s.png
Thank you.
Gautam.