Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgres-specific code removed #123

Merged
merged 8 commits into from
Jul 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions cacholote/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,9 @@ def init_database(connection_string: str, force: bool = False) -> sa.engine.Engi
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
alembic.command.stamp(alembic_cfg, "head")
else:
# check the structure is empty or incomplete
query = sa.text(
"SELECT table_name FROM information_schema.tables WHERE table_schema='public'"
)
conn = engine.connect()
if "cache_entries" not in conn.execute(query).scalars().all():
force = True
conn.close()
elif "cache_entries" not in sa.inspect(engine).get_table_names():
# db structure is empty or incomplete
force = True
if force:
# cleanup and create the schema
Base.metadata.drop_all(engine)
Expand Down