diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index adb0f894d..70ff207a7 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -257,7 +257,7 @@ def set_database_user(file_path: str, value: str, database_engine: str): def set_database_password(file_path: str, database_engine: str, value: str = None): database_password = set_flag( file_path, - f"!!!SET {database_engine.upper()}_USER!!!", + f"!!!SET {database_engine.upper()}_PASSWORD!!!", value=value, length=64, using_digits=True, @@ -266,6 +266,18 @@ def set_database_password(file_path: str, database_engine: str, value: str = Non return database_password +def set_mysql_root_password(file_path: str, database_engine: str, value: str = None): + database_root_password = set_flag( + file_path, + f"!!!SET {database_engine.upper()}_ROOT_PASSWORD!!!", + value=value, + length=74, + using_digits=True, + using_ascii_letters=True, + ) + return database_root_password + + def get_database_env_path(env: str, database_engine: str): local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres") production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres") @@ -345,6 +357,19 @@ def set_flags_in_envs(database_user, celery_flower_user, debug=False): value=DEBUG_VALUE if debug else None, ) + if selected_database == "mysql": + set_mysql_root_password( + get_database_env_path(env="local", database_engine=selected_database), + database_engine=selected_database, + value=DEBUG_VALUE if debug else None, + ) + + set_mysql_root_password( + get_database_env_path(env="prod", database_engine=selected_database), + database_engine=selected_database, + value=DEBUG_VALUE if debug else None, + ) + set_celery_flower_user(local_django_envs_path, value=celery_flower_user) set_celery_flower_password( local_django_envs_path, value=DEBUG_VALUE if debug else None diff --git a/{{cookiecutter.project_slug}}/.envs/.local/.postgres b/{{cookiecutter.project_slug}}/.envs/.local/.postgres index f190db8e6..7a11cb3ad 100644 --- a/{{cookiecutter.project_slug}}/.envs/.local/.postgres +++ b/{{cookiecutter.project_slug}}/.envs/.local/.postgres @@ -3,5 +3,5 @@ POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_DB={{ cookiecutter.project_slug }} -POSTGRES_USER=!!!SET POSTGRES_USER!!! -POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!! +POSTGRES_USER=!!!SET POSTGRESQL_USER!!! +POSTGRES_PASSWORD=!!!SET POSTGRESQL_PASSWORD!!! diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.postgres b/{{cookiecutter.project_slug}}/.envs/.production/.postgres index f190db8e6..7a11cb3ad 100644 --- a/{{cookiecutter.project_slug}}/.envs/.production/.postgres +++ b/{{cookiecutter.project_slug}}/.envs/.production/.postgres @@ -3,5 +3,5 @@ POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_DB={{ cookiecutter.project_slug }} -POSTGRES_USER=!!!SET POSTGRES_USER!!! -POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!! +POSTGRES_USER=!!!SET POSTGRESQL_USER!!! +POSTGRES_PASSWORD=!!!SET POSTGRESQL_PASSWORD!!!