We could add an additional sub-command to the tethys db commands that checks for the existence of a db, and the unless argument in the salt script could call that command.
Alternatively, we could check for the existence of the db inside the create_db_user function of the db_commands, and not try to create the db (and return an error) if the db already exists.
When running the Docker build the database creation step will fail if the docker is connecting to an existing database.
We could change the
unless
argument in the salt script so that it checks for the existence of the database before trying to create it.The easiest place to check for the existence of a database would be in the
db_commands
module with a command like:We could add an additional sub-command to the
tethys db
commands that checks for the existence of a db, and theunless
argument in the salt script could call that command.Alternatively, we could check for the existence of the db inside the
create_db_user
function of thedb_commands
, and not try to create the db (and return an error) if the db already exists.