add: webhook

This commit is contained in:
h z
2025-03-17 13:54:53 +00:00
parent acb1e2260f
commit 864b78641b
23 changed files with 473 additions and 43 deletions

View File

@@ -1,5 +1,3 @@
import os
import subprocess
from contextlib import contextmanager
from sqlalchemy.schema import CreateTable
@@ -21,15 +19,6 @@ def get_db():
finally:
db.close()
# def dump_db():
# try:
# os.environ['MYSQL_PWD'] = DB_PASSWORD
# dump_cmd = f"mysqldump --no-tablespaces -h {DB_HOST} -P {DB_PORT} -u {DB_USER} {DB_NAME} > /app/dump/db_dump.sql"
# subprocess.run(dump_cmd, shell=True, check=True)
# except subprocess.CalledProcessError as e:
# print(f"Failed to dump database: {e}")
# raise e
def clear_db():
with engine.connect() as conn:
conn.execute(text("SET FOREIGN_KEY_CHECKS = 0;"))
@@ -60,9 +49,9 @@ def init_payload():
for model in table_models:
print(str(CreateTable(model.__table__)))
print(f"MODEL -- {model}, {hasattr(model, '__pay_load__')}")
if hasattr(model, "__pay_load__"):
payload = model.__pay_load__[ENVIRONMENT]
print(f"MODEL -- {model}, {hasattr(model, '__payload__')}")
if hasattr(model, "__payload__"):
payload = model.__payload__[ENVIRONMENT]
print(f"- - [ - ] hasattr, {ENVIRONMENT} - {payload}")
stmt = insert(model.__table__).values(payload).prefix_with("IGNORE")
print(f"- - [ - ] {stmt}\n")
@@ -73,11 +62,6 @@ def init_payload():
def setup_db():
if DB_SCHEMA_UPDATED:
# try:
# dump_db()
# print("[ x ] db dumped")
# except Exception as e:
# print(f"[ x ] Failed to dump database: {e}")
clear_db()
print("[ x ] db cleared")
create_all()