Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete a Project #2369

Closed
mwaliczek opened this issue Jul 12, 2022 · 6 comments
Closed

Cannot delete a Project #2369

mwaliczek opened this issue Jul 12, 2022 · 6 comments

Comments

@mwaliczek
Copy link

When trying to delete a project and error occurs. Steps to reproduce:

1. Deploy the application as described in the deployment guide (having it with default settings).

2. Run the application as described in the deployment guide.

3. Navigate to Admin -> Settings -> Project and add a new project with Published status.

4. Deleting a project leads to an error like here:

Step4

An error is related to a Foreign Key settings in DB. Steps to reproduce:

1. Login to DB.

2. Find an ID of a project to delete.

3. Execute Delete for example: DELETE FROM "public"."projects" WHERE "id"='fa133ac8-71c1-4360-ae37-3730eae4c220';

4. Have foreign key constraint violation as below:

Step5

Executing ALTER TABLE projects_allowed_input_topics DROP CONSTRAINT fk_rails_91bda1f137 solves the deletion error on DB level but event without a foreign key constraint deleting from Web Interface does not work.
@alexander-cit
Copy link
Contributor

Thanks for the report and sorry it takes so long to get a reply!

I've just configured the OS version locally using this repo https://github.com/CitizenLabDotCo/citizenlab-docker, and your steps work fine for me. My .env diff looks like that (apart from secret keys added by sh install.sh):

-INITIAL_ADMIN_EMAIL=
-INITIAL_ADMIN_PASSWORD=
-INITIAL_ADMIN_FIRST_NAME=
-INITIAL_ADMIN_LAST_NAME=
+INITIAL_ADMIN_EMAIL=admin@citizenlab.co
+INITIAL_ADMIN_PASSWORD=democracy2.0
+INITIAL_ADMIN_FIRST_NAME=First
+INITIAL_ADMIN_LAST_NAME=Last
 
 # ***** CORE *****
 
 # The address of the platform, without https://
-CL_SETTINGS_HOST=
+CL_SETTINGS_HOST=localhost
 
-CL_SETTINGS_CORE_TIMEZONE=
+CL_SETTINGS_CORE_TIMEZONE=Brussels

I guess there's a chance something was broken and is fixed now. Could you run these commands to get the latest version?

cd citizenlab-docker
git pull
docker-compose pull

If you still see the error, could you take a screenshot of what your project form looks like before submitting it? Meanwhile, I will take a look at your other issues.

P.S. You see an error of DELETE SQL query because there are some records in projects_allowed_input_topics table that reference the record in projects table. Those records should be deleted by Rails. You can also try running docker-compose run web bin/rails c (opens Rails console) and then Project.order(created_at: :asc).last.destroy! (Ruby code to delete a project), and then post the output here.

@alexander-cit
Copy link
Contributor

@mwaliczek Could you please also run and show the output of this command after updating to the latest version?

docker-compose images

@mwaliczek
Copy link
Author

mwaliczek commented Aug 11, 2022

Hello,

Thank you for your answer and sorry for a late reply. I was stuck on another project. Unfortunately the problem still occurs, what I did:

cd citizenlab-docker
git pull
docker-compose pull

and then as you requested:

docker-compose run web bin/rails c
Project.order(created_at: :asc).last.destroy!

result:

err

and also please check the list after: docker-compose images:

img

@alexander-cit
Copy link
Contributor

Sorry, our upgrade process sometimes is a bit more complicated than just docker-compose pull.

If you want to preserve your data, you can try these commands #1449 (comment)

If you don't need your existing data, I would recommend running docker-compose run --rm web rake db:reset (destroys all the data in the database and creates it from scratch).

@mwaliczek
Copy link
Author

mwaliczek commented Aug 11, 2022

Before running docker-compose run --rm web rake db:reset i have added DISABLE_DATABASE_ENVIRONMENT_CHECK=1 to .env file according to displayed message

I did recreate db by running docker-compose run --rm web rake db:reset for test purposes and you are right, deleting the projects started working.

I have also tested update solution with preserving the data and it also works fine.

Thank you very much, I confirm that after:

cd citizenlab-docker
git pull
docker-compose pull
docker-compose stop
docker-compose run --rm web bin/rails db:migrate email_campaigns:assure_campaign_records cl2back:clear_cache_store email_campaigns:remove_deprecated
docker-compose run --rm web bin/rails runner "AppConfiguration.instance.tap { |c| c.cleanup_settings; c.save! }"
docker-compose up -d

Deleting project works ok and no data is missing.

@alexander-cit
Copy link
Contributor

Glad to hear it's solved! And thanks for the confirmation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants