Spaces:
Running
Running
File size: 828 Bytes
478dec6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import os
import dotenv
from config.constant import EnvPostgresConstants, EnvFilepath
dotenv.load_dotenv(EnvFilepath.ENVPATH)
from sqlalchemy import create_engine, text
from externals.databases.pg_models import Base
from utils.logger import get_logger
logger = get_logger("init schema")
def drop_tables():
try:
DATABASE_URL = EnvPostgresConstants.CONSTRING
engine = create_engine(DATABASE_URL)
# Create extension
with engine.connect() as conn:
conn.execute(text('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'))
conn.commit()
# Create tables
Base.metadata.drop_all(engine)
logger.info("✅ drop schema success")
except Exception as E:
logger.error(f"❌ drop schema failed, {E}")
if __name__ == "__main__":
drop_tables() |