Skip to content

Auto initialize database with algorithms #57

@ericbuckley

Description

@ericbuckley

Summary

We don't need the complexity of alembic, or at least not yet. What's really necessary is to build the database tables, and then load the default algorithms on startup. This will make the process of onboarding simple in the near future.

Acceptance Criteria

  • Default algorithms should be auto created when the API server starts up

Details / Tasks

  • Remove the alembic migrations and its dependencies from pyproject.toml
  • Create a new file assets/default_algorithms.yml and define the DIBBS Basic and DIBBS Enhanced algorithms in this file
    • Put plenty of comments in the file to describe the different elements
  • In recordlinker.database create a new function for initializing the database, it should invoke "models.Base.metadata.create_all"
  • The new function will also need to test to see if the Algorithms table has a default algorithm loaded, if so do nothing
  • If there is no default algorithm, it should load the algorithms defined in assets/default_algorithms.yml
  • If no default algorithm is defined in the yml file, it should raise an error
  • It should override any existing algorithms in the database with the same name

Background / Context

Currently, JSON is being used to store algorithms in text (or at least for our test cases). JSON doesn't allow for comments, which limits our ability to describe the process to the future user. We could put the documentation in another file, but typically keeping this close to the code as possible makes it more likely that the information will be used. YAML allows for comments and is generally more readable.

Dependencies

#24

Metadata

Metadata

Assignees

Labels

apiNew API feature

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions