in Education by
I'm trying to populate a database using seeder. I get an error: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (forge.projects, CONSTRAINT projects_status_id_foreign FOREIGN KEY (status_id) REFERENCES status_projects (id)) Here are my migrations: public function up() { Schema::create('projects', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('subtitle'); $table->longText('main_data'); $table->string('budget_description'); $table->integer('owner_id')->unsigned(); $table->integer('category_id')->unsigned(); $table->integer('deadline_id')->unsigned(); $table->integer('city_id')->unsigned(); $table->string('website')->nullable()->default('null'); //reference $table->decimal('budget', 18, 4); $table->integer('status_id')->unsigned()->default('1'); $table->dateTime('started_at')->nullable(); $table->integer('account_id')->unsigned()->default(1); $table->timestamps(); $table->softDeletes(); }); } This is a migration for Status: public function up() { Schema::create('status_projects', function (Blueprint $table) { $table->increments('id'); $table->string('name'); }); } Several people are working on this project, so I created an additional migration: public function up() { Schema::table('projects', function (Blueprint $table) { $table->unsignedInteger('status_id'); $table->foreign('status_id') ->references('id')->on('status_projects') ->onDelete('cascade'); }); } Now when I try to execute the command php artisan migrate I get error: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'status_id' (SQL: alter table projects add status_id int unsigned null) How can I fix this? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This should solve the problem: you have to refresh your database (ps: you are going to re-insert your rows) php artisan migrate refresh

Related questions

0 votes
    If a student gains unauthorized access to the student database and modifies his/her marks, what type of violation would it be? (1)Confidentiality (2)Both the options (3)Integrity...
asked Mar 22, 2021 in Technology by JackTerrance
0 votes
    To include integrity constraint in an existing relation use : (a) Create table (b) Modify table (c) ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    Which of the following can be addressed by enforcing a referential integrity constraint? (a) All phone ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I am using Laravel 5.7 version. I got the below error for users_activations table while run the command ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I am using Laravel 5.7 version. I got the below error for users_activations table while run the command ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm pretty new at laravel, in fact and I'm trying to create my very first project. for some ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    I am trying to create authentication using Laravel Passport, I have configured everything the right way as ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Accountability is another important security concept. How is Accountability related to non-repudiation and integrity? Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    How can we temporarily disable a foreign key constraint in MySQL?...
asked Feb 1, 2021 in Technology by JackTerrance
0 votes
    Which institute/organisation is responsible for taking action against violation of human rights? (a) Self Help ... National Investigation Agency Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    Which of the following refers to the violation of the principle if a computer is no more accessible? Access control Confidentiality Availability All of the above...
asked Mar 4, 2021 in Technology by JackTerrance
0 votes
    Humphreys collecting data for the Tearoom Trade study under the pretense that he was a lookout is an example of a violation of the principle of:...
asked Mar 1, 2021 in Education by Editorial Staff
0 votes
    The researcher's failure to protect research subjects from deductive disclosure is the primary ethical violation in which of the following studies?...
asked Mar 1, 2021 in Education by Editorial Staff
0 votes
    When integrity is lacking in a security system, _________ occurs. (a) Database hacking (b) Data deletion (c) Data ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 5, 2021 in Education by JackTerrance
0 votes
    Why these 4 elements (confidentiality, integrity, authenticity & availability) are considered fundamental? (a) They help ... questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 5, 2021 in Education by JackTerrance
...