[fix] Avoid to revert migrations without backward routine

This commit is contained in:
ljf 2019-08-14 12:07:39 +02:00
parent 74b5ea5982
commit fc426cff69
11 changed files with 10 additions and 32 deletions

View file

@ -19,10 +19,6 @@ class MyMigration(Migration):
"Migrate Dyndns stuff from MD5 TSIG to SHA512 TSIG"
def backward(self):
# Not possible because that's a non-reversible operation ?
pass
def migrate(self, dyn_host="dyndns.yunohost.org", domain=None, private_key_path=None):
if domain is None or private_key_path is None:

View file

@ -29,11 +29,7 @@ class MyMigration(Migration):
mode = "manual"
def backward(self):
raise YunohostError("migration_backward_impossible", name=self.name)
def migrate(self):
def forward(self):
self.logfile = "/var/log/yunohost/{}.log".format(self.name)

View file

@ -24,7 +24,7 @@ class MyMigration(Migration):
dependencies = ["migrate_to_stretch"]
def migrate(self):
def forward(self):
# Get list of php5 pool files
php5_pool_files = glob.glob("{}/*.conf".format(PHP5_POOLS))

View file

@ -16,7 +16,7 @@ class MyMigration(Migration):
dependencies = ["migrate_to_stretch"]
def migrate(self):
def forward(self):
if not self.package_is_installed("postgresql-9.4"):
logger.warning(m18n.n("migration_0005_postgresql_94_not_installed"))
@ -34,10 +34,6 @@ class MyMigration(Migration):
subprocess.check_call("pg_dropcluster --stop 9.4 main", shell=True)
subprocess.check_call("service postgresql start", shell=True)
def backward(self):
pass
def package_is_installed(self, package_name):
p = subprocess.Popen("dpkg --list | grep '^ii ' | grep -q -w {}".format(package_name), shell=True)

View file

@ -20,16 +20,13 @@ class MyMigration(Migration):
"Synchronize admin and root passwords"
def migrate(self):
def forward(self):
new_hash = self._get_admin_hash()
self._replace_root_hash(new_hash)
logger.info(m18n.n("root_password_replaced_by_admin_password"))
def backward(self):
pass
@property
def mode(self):

View file

@ -34,7 +34,7 @@ class MyMigration(Migration):
use the recommended configuration, with an appropriate disclaimer.
"""
def migrate(self):
def forward(self):
# Check if deprecated DSA Host Key is in config
dsa_rgx = r'^[ \t]*HostKey[ \t]+/etc/ssh/ssh_host_dsa_key[ \t]*(?:#.*)?$'

View file

@ -35,7 +35,7 @@ class MyMigration(Migration):
dependencies = ["ssh_conf_managed_by_yunohost_step1"]
def migrate(self):
def forward(self):
settings_set("service.ssh.allow_deprecated_dsa_hostkey", False)
regen_conf(names=['ssh'], force=True)
@ -44,10 +44,6 @@ class MyMigration(Migration):
if os.path.isdir(ARCHIVES_PATH):
chown(ARCHIVES_PATH, uid="admin", gid="root")
def backward(self):
raise YunohostError("migration_backward_impossible", name=self.name)
@property
def mode(self):

View file

@ -17,7 +17,7 @@ class MyMigration(Migration):
Decouple the regen conf mechanism from the concept of services
"""
def migrate(self):
def forward(self):
if "conffiles" not in read_file("/etc/yunohost/services.yml") \
or os.path.exists(REGEN_CONF_FILE):
@ -37,6 +37,3 @@ class MyMigration(Migration):
# (Actually save the modification of services)
_save_services(services)
def backward(self):
pass

View file

@ -15,7 +15,7 @@ class MyMigration(Migration):
"Migrate from official.json to apps.json"
def migrate(self):
def forward(self):
# Backup current app list json
os.system("cp %s %s" % (APPSLISTS_JSON, APPSLISTS_BACKUP))

View file

@ -92,7 +92,7 @@ class MyMigration(Migration):
app_setting(app, 'allowed_users', delete=True)
def migrate(self):
def forward(self):
# Check if the migration can be processed
ldap_regen_conf_status = regen_conf(names=['slapd'], dry_run=True)
# By this we check if the have been customized

View file

@ -1316,7 +1316,7 @@ class Migration(object):
raise NotImplementedError()
def backward(self):
pass
raise YunohostError("migration_backward_impossible", name=self.name)
@property
def disclaimer(self):