mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-25 12:32: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()
|
db.commit()
|
||||||
else:
|
else:
|
||||||
logger.info(f"Resetting the main SQL tables in {db.bind}.")
|
logger.info(f"Resetting the main SQL tables in {db.bind}.")
|
||||||
for table in Base.metadata.sorted_tables:
|
tables = [
|
||||||
if str(table) == entities.MissingCompany.__tablename__:
|
table
|
||||||
continue
|
for table in Base.metadata.sorted_tables
|
||||||
logger.debug(f"Dropping {table}")
|
if str(table) != entities.MissingCompany.__tablename__
|
||||||
table.drop(db.bind)
|
]
|
||||||
db.commit()
|
logger.debug(f"Dropping tables: {', '.join([str(_) for _ in tables])}")
|
||||||
|
Base.metadata.drop_all(db.bind, tables=tables)
|
||||||
|
db.commit()
|
||||||
init_db(db)
|
init_db(db)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
def cli() -> None:
|
def cli() -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user