Error: 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 subscriptions
(id
bigint unsigned not null auto_increment primary key, month
int unsigned not null auto_increment primary key, price
int unsigned not null auto_increment primary key, status tinyint not null default ‘1’, created_at
timestamp null, updated_at
timestamp null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)
I have applied this code given below:
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->integer('month',4);
$table->integer('price',7);
$table->tinyInteger('status')->default(1);
$table->timestamps();
});
} ```
2
Answers
You can’t set a size on integers.
It should be like this:
first of all, you can’t set size on integers second instead of tinyInteger use boolean
and I would suggest using decimal for price because it may contain a decimal places