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

Reactivate aerich #101

Merged
merged 6 commits into from
Aug 29, 2024

Conversation

tsagadar
Copy link
Collaborator

Giving aerich another shot - as we need a database migration mechanism for proper deployments.

Mainly removes the automated aerich tasks from application startup and leaves these steps to be
triggered by the developer or ops person (see also commit messages)

Let's see if upcoming model changes can be expressed by aerich as migrations.

Fixes #48

goosebit/db/db.py Outdated Show resolved Hide resolved
goosebit/settings/schema.py Show resolved Hide resolved
Constant should point to root of the project. Non-source files should
be persisted there rather than in the goosebit folder.
Removes all aerich automated activities from the app startup. The following
actions should be manually triggered by the different roles

Developer
- Before running gooseBit for the first time, run `poetry run aerich upgrade`.
- After pulling an update from gooseBit with model changes, run
  `poetry run aerich upgrade`.
- After implementing model changes, run `poetry run aerich migrate` and commit
  the migration file together with the model changes.

Ops
- When setting up gooseBit initially, create database and configure db_uri.
- When deploying gooseBit, make sure to call `aerich upgrade` before
  launching the service to ensure the database has the proper schema.

Also in this commit (hard to separate):
- moves the database config into the db folder.
- slightly improves README.md. More work required, but waiting for docu
  duplication issue was addressed.
- remove setting DB_MIGRATIONS_LOC
- move migrations into goosebit/db
This code can be convenient for the developer but could be dangerous when
running in production. Deleting software will also delete linked rollouts,
so something that should not be done lightly.

Finally, the code would be in the wrong place - not closely connected with
the database init.
db already initialized through the lifespan in goosebit/__init.py__
@tsagadar tsagadar merged commit 7bfc1a1 into UpstreamDataInc:master Aug 29, 2024
2 checks passed
@tsagadar tsagadar deleted the mm/reactivate-aerich branch August 29, 2024 15:45
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.

Database migrations
3 participants