diff --git a/build/common/commands/constants.py b/build/common/commands/constants.py index b07e3381..48093f13 100644 --- a/build/common/commands/constants.py +++ b/build/common/commands/constants.py @@ -7,4 +7,6 @@ DB_PORT = 3306 APP_VERSIONS_JSON_FILE = 'app_versions.json' APPS_TXT_FILE = 'apps.txt' COMMON_SITE_CONFIG_FILE = 'common_site_config.json' -DATE_FORMAT = "%Y%m%d_%H%M%S" \ No newline at end of file +DATE_FORMAT = "%Y%m%d_%H%M%S" +RDS_DB = 'rds_db' +RDS_PRIVILEGES = "SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, LOCK TABLES" diff --git a/build/common/commands/new.py b/build/common/commands/new.py index 57c9f978..5babe6c3 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -4,7 +4,7 @@ import semantic_version from frappe.commands.site import _new_site from frappe.installer import update_site_config -from constants import COMMON_SITE_CONFIG_FILE +from constants import COMMON_SITE_CONFIG_FILE, RDS_DB, RDS_PRIVILEGES from utils import ( run_command, get_config, @@ -93,7 +93,13 @@ def main(): run_command(command) # Grant permission to database - command = mysql_command + [f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] + grant_privileges = "ALL PRIVILEGES" + + # for Amazon RDS + if config.get(RDS_DB) or site_config.get(RDS_DB): + grant_privileges = RDS_PRIVILEGES + + command = mysql_command + [f"GRANT {grant_privileges} ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] run_command(command) if frappe.redis_server: