Skip to content
This repository was archived by the owner on Feb 3, 2024. It is now read-only.

Commit a3cb5fb

Browse files
mxmeinholdjabbate19
authored andcommitted
Reformat and reword migrations readme
1 parent 66daf7c commit a3cb5fb

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

migrations/README

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
Generic single-database configuration.
2-
3-
Q: What is Alembic/Migrations?
4-
A: Migrations give a versioned history of changes to the SQL Schema for this project. A "revision" defines changes to a table (add/drop tables or columns). This allows you to go back in time if needed, and quickly re-create the whole schema for a local development
5-
6-
Q: How do I update my local database to use the migrations?
7-
A: (1) Add your URI to config.py, depending on how you are doing it. (2) Run "flask db upgrade"
8-
9-
Q: I made changes to the models.py file and need a new revision. How do I do that?
10-
A: flask db revision -m "Whatever you want to name it"
11-
1+
## What are Alembic and migrations?
2+
Migrations give a versioned history of changes to the SQL Schema for this project.
3+
A `revision` or `migration` defines changes to the structure of the database (such as adding/dropping tables or columns), as well as procedures for migrating existing data to the new structure. Migrations allow for safe(ish) rollbacks, and make it easier to make incremental changes to the database.
4+
5+
## Applying migrations
6+
Once you have your db URI in `config.py`, run `flask db upgrade` to bring the db up to the latest revision.
7+
8+
## Creating new revisions
9+
When you change `models.py`, you'll need to make a new migration.
10+
Run `flask db revision -m "<descriptive title>"` to autogenerate one.
11+
You should go manually inspect the created revision to make sure it does what you expect.
12+
Once you've got your changes all set, be sure to commit the migration file in the same commit as your changes to `models.py`

0 commit comments

Comments
 (0)