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

LIN-381 database migration script #704

Merged
merged 60 commits into from
Jul 8, 2022

Conversation

joshpoll
Copy link
Contributor

@joshpoll joshpoll commented Jun 21, 2022

Description

Implements database migration using alembic.
Fixes LIN-381 and LIN-471

(For Lineapy users) To upgrade a Lineapy database

Nothing! When you use a lineapy db it will be upgraded automatically.

(For Lineapy developers) To create a migration

Run alembic revision -m "<description of change>". This will generate a migration template in the alembic/versions directory.

Then implement the migration scripts using the alembic package in the the bodies of the upgrade and downgrade functions.

See https://alembic.sqlalchemy.org/en/latest/tutorial.html#create-a-migration-script for more information.

Alternately, we can also use alembic's autogeneration feature and run alembic revision --autogenerate -m "<description of change>". More details at: https://alembic.sqlalchemy.org/en/latest/autogenerate.html

Note: The alembic version of a DB is stored in the alembic_version table, which has a single column named version_num.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Currently I have tested this by running a small example migration that adds a python version to the table, and I have run the CLI to upgrade it. I have not yet created more involved tests.

@joshpoll joshpoll changed the title Lin 381 database migration script LIN-381 database migration script Jun 21, 2022
@joshpoll
Copy link
Contributor Author

To clarify, where should I put the user-facing docs? In the main readme (and if so where) or somewhere else?

lineapy/db/db.py Outdated Show resolved Hide resolved
lineapy/db/db.py Outdated Show resolved Hide resolved
lineapy/cli/cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@lionsardesai lionsardesai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ship it!!!!

Copy link
Contributor

@lionsardesai lionsardesai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shit it 😂

@lionsardesai lionsardesai merged commit df9c410 into main Jul 8, 2022
@lionsardesai lionsardesai deleted the LIN-381-database-migration-script branch July 8, 2022 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants