mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add migration for postgresql 13->15 after migrating to bookworm
This commit is contained in:
parent
1a85521f1f
commit
4b8506f71f
1 changed files with 15 additions and 15 deletions
|
@ -13,9 +13,9 @@ logger = getLogger("yunohost.migration")
|
||||||
|
|
||||||
|
|
||||||
class MyMigration(Migration):
|
class MyMigration(Migration):
|
||||||
"Migrate DBs from Postgresql 11 to 13 after migrating to Bullseye"
|
"Migrate DBs from Postgresql 13 to 15 after migrating to Bookworm"
|
||||||
|
|
||||||
dependencies = ["migrate_to_bullseye"]
|
dependencies = ["migrate_to_bookworm"]
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if (
|
if (
|
||||||
|
@ -27,37 +27,37 @@ class MyMigration(Migration):
|
||||||
logger.info("No YunoHost app seem to require postgresql... Skipping!")
|
logger.info("No YunoHost app seem to require postgresql... Skipping!")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.package_is_installed("postgresql-11"):
|
if not self.package_is_installed("postgresql-13"):
|
||||||
logger.warning(m18n.n("migration_0023_postgresql_11_not_installed"))
|
logger.warning(m18n.n("migration_0029_postgresql_13_not_installed"))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.package_is_installed("postgresql-13"):
|
if not self.package_is_installed("postgresql-15"):
|
||||||
raise YunohostValidationError("migration_0023_postgresql_13_not_installed")
|
raise YunohostValidationError("migration_0029_postgresql_15_not_installed")
|
||||||
|
|
||||||
# Make sure there's a 11 cluster
|
# Make sure there's a 13 cluster
|
||||||
try:
|
try:
|
||||||
self.runcmd("pg_lsclusters | grep -q '^11 '")
|
self.runcmd("pg_lsclusters | grep -q '^13 '")
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"It looks like there's not active 11 cluster, so probably don't need to run this migration"
|
"It looks like there's not active 13 cluster, so probably don't need to run this migration"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not space_used_by_directory(
|
if not space_used_by_directory(
|
||||||
"/var/lib/postgresql/11"
|
"/var/lib/postgresql/13"
|
||||||
) > free_space_in_directory("/var/lib/postgresql"):
|
) > free_space_in_directory("/var/lib/postgresql"):
|
||||||
raise YunohostValidationError(
|
raise YunohostValidationError(
|
||||||
"migration_0023_not_enough_space", path="/var/lib/postgresql/"
|
"migration_0029_not_enough_space", path="/var/lib/postgresql/"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.runcmd("systemctl stop postgresql")
|
self.runcmd("systemctl stop postgresql")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.runcmd(
|
self.runcmd(
|
||||||
"LC_ALL=C pg_dropcluster --stop 13 main || true"
|
"LC_ALL=C pg_dropcluster --stop 15 main || true"
|
||||||
) # We do not trigger an exception if the command fails because that probably means cluster 13 doesn't exists, which is fine because it's created during the pg_upgradecluster)
|
) # We do not trigger an exception if the command fails because that probably means cluster 15 doesn't exists, which is fine because it's created during the pg_upgradecluster)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.runcmd("LC_ALL=C pg_upgradecluster -m upgrade 11 main")
|
self.runcmd("LC_ALL=C pg_upgradecluster -m upgrade 13 main")
|
||||||
self.runcmd("LC_ALL=C pg_dropcluster --stop 11 main")
|
self.runcmd("LC_ALL=C pg_dropcluster --stop 13 main")
|
||||||
self.runcmd("systemctl start postgresql")
|
self.runcmd("systemctl start postgresql")
|
||||||
|
|
||||||
def package_is_installed(self, package_name):
|
def package_is_installed(self, package_name):
|
Loading…
Add table
Reference in a new issue