mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Have a function to initialize migrations
This commit is contained in:
parent
3a2464dfb4
commit
3ca8c089e1
1 changed files with 20 additions and 2 deletions
|
@ -432,7 +432,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
|||
_install_appslist_fetch_cron()
|
||||
|
||||
# Init migrations (skip them, no need to run them on a fresh system)
|
||||
tools_migrations_migrate(skip=True, auto=True)
|
||||
_skip_all_migrations()
|
||||
|
||||
os.system('touch /etc/yunohost/installed')
|
||||
|
||||
|
@ -948,7 +948,6 @@ def tools_migrations_migrate(target=None, skip=False, auto=False, accept_disclai
|
|||
|
||||
write_to_json(MIGRATIONS_STATE_PATH, state)
|
||||
|
||||
|
||||
def tools_migrations_state():
|
||||
"""
|
||||
Show current migration state
|
||||
|
@ -1048,6 +1047,25 @@ def _load_migration(migration_file):
|
|||
raise MoulinetteError(errno.EINVAL, m18n.n('migrations_error_failed_to_load_migration',
|
||||
number=number, name=name))
|
||||
|
||||
def _skip_all_migrations():
|
||||
"""
|
||||
Skip all pending migrations.
|
||||
This is meant to be used during postinstall to
|
||||
initialize the migration system.
|
||||
"""
|
||||
state = tools_migrations_state()
|
||||
|
||||
# load all migrations
|
||||
migrations = _get_migrations_list()
|
||||
migrations = sorted(migrations, key=lambda x: x.number)
|
||||
last_migration = migrations[-1]
|
||||
|
||||
state["last_run_migration"] = {
|
||||
"number": last_migration.number,
|
||||
"name": last_migration.name
|
||||
}
|
||||
write_to_json(MIGRATIONS_STATE_PATH, state)
|
||||
|
||||
|
||||
class Migration(object):
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue