Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public function up()
  2. {
  3. Schema::create('location_areas', function (Blueprint $table) {
  4. $table->smallIncrements('id', 4)->unsigned();
  5. $table->string('name', 50)->unique();
  6. $table->smallInteger('location_region_id', 4)->unsigned();
  7.  
  8.  
  9. $table->foreign('location_region_id')->references('id')
  10. ->on('location_regions')->onDelete('cascade');
  11.  
  12. $table->engine = 'InnoDB';
  13. $table->charset = 'utf8';
  14. $table->collation = 'utf8_general_ci';
  15. });
  16. }
  17.  
  18. Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `location_areas` (`id` smallint unsigned not null auto_increment primary key, `name` varchar(50) not null, `location_region_id` smallint unsigned not null auto_increment primary key) default character set utf8 collate 'utf8_general_ci' engine = InnoDB)
  19.  
  20. Если убрать ограничения, то все работает как надо.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement