2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2025-01-11 09:35:12 +00:00

fix: condition for mariadb grants for aws rds

This commit is contained in:
Revant Nandgaonkar 2020-07-16 06:06:48 +05:30
parent 9a22832389
commit c2ebdfcf8b
2 changed files with 8 additions and 6 deletions

View File

@ -9,3 +9,4 @@ APPS_TXT_FILE = 'apps.txt'
COMMON_SITE_CONFIG_FILE = 'common_site_config.json'
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"

View File

@ -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, RDS_DB
from constants import COMMON_SITE_CONFIG_FILE, RDS_DB, RDS_PRIVILEGES
from utils import (
run_command,
get_config,
@ -93,13 +93,14 @@ def main():
run_command(command)
# Grant permission to database
command = mysql_command + [f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"]
run_command(command)
grant_privileges = "ALL PRIVILEGES"
# for Amazon RDS
if config.get(RDS_DB) or site_config.get(RDS_DB):
command = mysql_command + [f"GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, LOCK TABLES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"]
run_command(command)
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:
frappe.redis_server.connection_pool.disconnect()