add: webhook
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user