[enh] Avoid to modify untestable migrations

This commit is contained in:
ljf 2019-08-14 17:39:23 +02:00
parent 0a2ba102c8
commit f98ad4f191

View file

@ -72,28 +72,28 @@ class MyMigration(Migration):
# Reload nginx # Reload nginx
_run_service_command("reload", "nginx") _run_service_command("reload", "nginx")
def backward(self): def backward(self):
# Get list of php7 pool files # Get list of php7 pool files
php7_pool_files = glob.glob("{}/*.conf".format(PHP7_POOLS)) php7_pool_files = glob.glob("{}/*.conf".format(PHP7_POOLS))
# Keep only files which have the migration comment # Keep only files which have the migration comment
php7_pool_files = [f for f in php7_pool_files if open(f).readline().strip() == MIGRATION_COMMENT] php7_pool_files = [f for f in php7_pool_files if open(f).readline().strip() == MIGRATION_COMMENT]
# Delete those files # Delete those files
for f in php7_pool_files: for f in php7_pool_files:
os.remove(f) os.remove(f)
# Reload/restart the php pools # Reload/restart the php pools
_run_service_command("stop", "php7.0-fpm") _run_service_command("stop", "php7.0-fpm")
os.system("systemctl start php5-fpm") os.system("systemctl start php5-fpm")
# Get list of nginx conf file # Get list of nginx conf file
nginx_conf_files = glob.glob("/etc/nginx/conf.d/*.d/*.conf") nginx_conf_files = glob.glob("/etc/nginx/conf.d/*.d/*.conf")
for f in nginx_conf_files: for f in nginx_conf_files:
# Replace the socket prefix if it's found # Replace the socket prefix if it's found
c = "sed -i -e 's@{}@{}@g' {}".format(PHP7_SOCKETS_PREFIX, PHP5_SOCKETS_PREFIX, f) c = "sed -i -e 's@{}@{}@g' {}".format(PHP7_SOCKETS_PREFIX, PHP5_SOCKETS_PREFIX, f)
os.system(c) os.system(c)
# Reload nginx # Reload nginx
_run_service_command("reload", "nginx") _run_service_command("reload", "nginx")