This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2020-12-20 21:04:29 +00:00
|
|
|
# flake8: noqa
|
|
|
|
from lifecycle.migrate import BaseMigration
|
|
|
|
|
2023-10-16 15:28:53 +00:00
|
|
|
SQL_STATEMENT = """BEGIN TRANSACTION;
|
|
|
|
ALTER TABLE authentik_audit_event RENAME TO authentik_events_event;
|
2020-12-20 21:04:29 +00:00
|
|
|
UPDATE django_migrations SET app = replace(app, 'authentik_audit', 'authentik_events');
|
2023-10-16 15:28:53 +00:00
|
|
|
UPDATE django_content_type SET app_label = replace(app_label, 'authentik_audit', 'authentik_events');
|
|
|
|
|
|
|
|
COMMIT;"""
|
2020-12-20 21:04:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(BaseMigration):
|
|
|
|
def needs_migration(self) -> bool:
|
|
|
|
self.cur.execute(
|
|
|
|
"select * from information_schema.tables where table_name = 'authentik_audit_event';"
|
|
|
|
)
|
|
|
|
return bool(self.cur.rowcount)
|
|
|
|
|
|
|
|
def run(self):
|
2023-10-06 16:56:10 +00:00
|
|
|
with self.con.transaction():
|
|
|
|
self.cur.execute(SQL_STATEMENT)
|