tethysplatform / tethys

The Tethys Platform main Django website project repository.
http://tethysplatform.org/
BSD 2-Clause "Simplified" License
92 stars 49 forks source link

Nonexit Tethys Create DB CLI Command #1087

Closed ckrew closed 1 week ago

ckrew commented 2 weeks ago

Description

This merge request addresses an issue with the tethys db create CLI command. The issue occurs when multiple portals are trying to share a single database with the same tethys_super table. If the tethys_super table already exists, then the tethys db create CLI command will try to create the tethys_super table, fail to do so, and then exit before the table for the portal is created.

This merge request sets the exit_on_error to False for the create_db_user call inside of the create_tethys_db function. This will ensure that both create_db_user calls are executed, whether they are successful or not. To keep the same behavior currently where the create_tethys_db function can exit on an error, I have added a exit_creation_on_error argument to the function. If set to True, then the function will exit if either one of the create_db_user calls fails.

I also updated the logging in the create_tethys_db function to give more details on what user or database is being created

Steps to reproduce

Quality Checks

coveralls commented 2 weeks ago

Coverage Status

coverage: 99.936%. remained the same when pulling 41aa26e50caa464ab0b047bb99a208298d630ca5 on cli_db_create_nonfail into fbf295d1886b42512f3df6895694b3fc8d1b7c04 on main.

ckrew commented 2 weeks ago

Removing the "SUPERUSER" role as part of this PR to cover #1069

ckrew commented 2 weeks ago

Removing the "SUPERUSER" role as part of this PR to cover #1069

This actually caused the tests to fail so I added it back in so we could get this merged.