lifecycle: fix migration trying to load all classes
This commit is contained in:
parent
ac4c314042
commit
597188c7ee
|
@ -47,7 +47,9 @@ if __name__ == "__main__":
|
||||||
# pyright: reportGeneralTypeIssues=false
|
# pyright: reportGeneralTypeIssues=false
|
||||||
spec.loader.exec_module(mod)
|
spec.loader.exec_module(mod)
|
||||||
|
|
||||||
for _, sub in getmembers(mod, isclass):
|
for name, sub in getmembers(mod, isclass):
|
||||||
|
if name != "Migration":
|
||||||
|
continue
|
||||||
migration = sub(curr, conn)
|
migration = sub(curr, conn)
|
||||||
if migration.needs_migration():
|
if migration.needs_migration():
|
||||||
LOGGER.info("Migration needs to be applied", migration=sub)
|
LOGGER.info("Migration needs to be applied", migration=sub)
|
||||||
|
|
|
@ -25,7 +25,8 @@ delete from django_migrations where app = 'passbook_stages_password' and
|
||||||
name = '0002_passwordstage_change_flow';"""
|
name = '0002_passwordstage_change_flow';"""
|
||||||
|
|
||||||
|
|
||||||
class To010Migration(BaseMigration):
|
class Migration(BaseMigration):
|
||||||
|
|
||||||
def needs_migration(self) -> bool:
|
def needs_migration(self) -> bool:
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
"select * from information_schema.tables where table_name='oidc_provider_client'"
|
"select * from information_schema.tables where table_name='oidc_provider_client'"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from pickle import loads # nosec
|
from pickle import loads
|
||||||
|
from typing import Any # nosec
|
||||||
|
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
|
|
||||||
|
@ -6,8 +7,10 @@ from lifecycle.migrate import BaseMigration
|
||||||
from passbook.lib.config import CONFIG
|
from passbook.lib.config import CONFIG
|
||||||
|
|
||||||
|
|
||||||
class To012Migration(BaseMigration):
|
class Migration(BaseMigration):
|
||||||
def __init__(self) -> None:
|
|
||||||
|
def __init__(self, cur: Any, con: Any):
|
||||||
|
super().__init__(cur, con)
|
||||||
self.redis = Redis(
|
self.redis = Redis(
|
||||||
host=CONFIG.y("redis.host"),
|
host=CONFIG.y("redis.host"),
|
||||||
port=6379,
|
port=6379,
|
||||||
|
|
Reference in New Issue