0

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 2

0

You can't set a size on integers.

It should be like this:

 $table->integer('month');
 $table->integer('price');

Sign up to request clarification or add additional context in comments.

Comments

0

first of all, you can't set size on integers second instead of tinyInteger use boolean

    {
        Schema::create('subscriptions', function (Blueprint $table) {
            $table->id();
            $table->integer('month');
            $table->integer('price');
            $table->boolean('status')->default(1);
            $table->timestamps();
        });
    }

and I would suggest using decimal for price because it may contain a decimal places

table->decimal('price', 10, 6)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.