mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-25 00:22:34 +02:00
Fixed sql alchemy reset order. (#383)
There was a problem on the PG variant. The SQLite variant worked. Now resetting properly also on PG.
This commit is contained in:
parent
7c1fac28fd
commit
119a3edfca
@ -26,13 +26,16 @@ def reset_tables(db: Session, all_tables: bool = False) -> None:
|
||||
db.commit()
|
||||
else:
|
||||
logger.info(f"Resetting the main SQL tables in {db.bind}.")
|
||||
for table in Base.metadata.sorted_tables:
|
||||
if str(table) == entities.MissingCompany.__tablename__:
|
||||
continue
|
||||
logger.debug(f"Dropping {table}")
|
||||
table.drop(db.bind)
|
||||
db.commit()
|
||||
tables = [
|
||||
table
|
||||
for table in Base.metadata.sorted_tables
|
||||
if str(table) != entities.MissingCompany.__tablename__
|
||||
]
|
||||
logger.debug(f"Dropping tables: {', '.join([str(_) for _ in tables])}")
|
||||
Base.metadata.drop_all(db.bind, tables=tables)
|
||||
db.commit()
|
||||
init_db(db)
|
||||
db.commit()
|
||||
|
||||
|
||||
def cli() -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user