John Davidson

php - Set non primary column as Auto Increment in Laravel

0 comments
Message:


This is my migration file code


Schema::create('hierarchies', function (Blueprint $table) {
$table->integer('id');
$table->integer('hierarchy_id');
$table->timestamps();
});

I want my ID column will be auto increment without primary and hierarchy_id will be my primary key.
How to do that?



My Answer:
increments('id');
$table->string('name');
$table->integer('parent_id')->unsigned()->nullable();
$table->integer('order')->unsigned()->autoIncrement();
});

Rate this post

3 of 5 based on 8464 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us