Duplication Error

Posted In Laravel
  • nurdaulet-shamilov 3 months ago
    I am getting this error:
      Illuminate\Database\QueryException  : SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'chatter_category_id' (SQL: alter table `chatter_discussion` add `chatter_category_id` int unsigned not null, add `user_id` bigint unsigned not null)
    	
    	My Migration file is this
    				
    				Schema::table('chatter_discussion', function (Blueprint $table) {
                $table->integer('chatter_category_id')->unsigned()->index();
                $table->foreign('chatter_category_id')->references('id')->on('chatter_categories')
                            ->onDelete('cascade')
                            ->onUpdate('cascade');
                $table->bigInteger('user_id')->unsigned()->index();
                $table->foreign('user_id')->references('id')->on('users')
                            ->onDelete('cascade')
                            ->onUpdate('cascade');
            });
            Schema::table('chatter_post', function (Blueprint $table) {
                $table->integer('chatter_discussion_id')->unsigned()->index();
                $table->foreign('chatter_discussion_id')->references('id')->on('chatter_discussion')
                            ->onDelete('cascade')
                            ->onUpdate('cascade');
                $table->bigInteger('user_id')->unsigned()->index();
                $table->foreign('user_id')->references('id')->on('users')
                            ->onDelete('cascade')
                            ->onUpdate('cascade');
            });

    I am getting this error: Illuminate\Database\QueryException : SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'chatter_category_id' (SQL: alter table chatter_discussion add chatter_category_id int unsigned not null, add user_id bigint unsigned not null)

    My Migration file is this
    			
    			Schema::table('chatter_discussion', function (Blueprint $table) {
            $table->integer('chatter_category_id')->unsigned()->index();
            $table->foreign('chatter_category_id')->references('id')->on('chatter_categories')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');
            $table->bigInteger('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');
        });
        Schema::table('chatter_post', function (Blueprint $table) {
            $table->integer('chatter_discussion_id')->unsigned()->index();
            $table->foreign('chatter_discussion_id')->references('id')->on('chatter_discussion')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');
            $table->bigInteger('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');
        });
    

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
tnylea
Cheers Friend!

I'm Tony, the creator of this site. I'm trying to increase my twitter following. Want to follow me?

Follow @tnylea If not, no worries :)