cancervariants / cancervariants/gene-normalization

PostgresDatabase recreates schema on startup

Open
#424 0 comments 0 reactions 1 assignee Claimed by @jsstevenson View on GitHub
bug
Dominant language
Python
Stars
3
Forks
4
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Right now the `PostgresDatabase` class recreates the database in it's `__init__` function.

The results in the schema being recreated every time the class is instantiated, regardless of if the schema already exists.

This is most problematic when the gene-normalizer user doesn't have permission to create tables, because it results in a failure, even if the schema is already setup and readable by that user.

### Steps to reproduce

Instantiate `PostgresDatabase`

### Expected behavior

The schema is used as-is if it already exists.

### Current behavior

The schema is recreated, even if it already exists.

### Acceptance Criteria

The `PostgresDatabase` class works if its db user has read-access to a pre-setup database.

### Possible reason(s)

_No response_

### Suggested fix

Modify [`check_schema_initialized`](https://github.com/cancervariants/gene-normalization/blob/main/src/gene/database/postgresql.py#L130) to check if the schema is initialized, rather than recreating that schema.

### Branch, commit, and/or version

main

### Screenshots

_No response_

### Environment details

Not relevant.

### Additional details

_No response_

### Contribution

None

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.