<commit_before>
# Migrations

Database migrations are built in in Edmunds using Flask-Migrate.


## Usage

Edmunds has already integrated the db-command in the application's manager.
You can use it as described in the Flask-Migrate-documentation:
```bash
python manage.py db --help
```

Usage of Flask-Migrate documentation:
* [Flask-Migrate](https://flask-migrate.readthedocs.io)

### Models

Models are used by Flask-Migrate to describe your database structure.
Add your model to `app.models` so they are picked up by the
migration-service:
```python
# app/models/mymodel.py

from edmunds.database.model import db, Model

class MyModel(Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(128))
```

> Note: If you want to customize the package where the migrate-service looks
> for models, you can override it in your config:
> ```python
> APP = {
>     'database': {
>         # ...
>         'models': {
>             'my/location/to/the/models',
>             'second/location/to/other/models',
>         },
>     },
> }
> ```
> The described paths are relative to the root-folder of your application.<commit_msg>#11: Improved migration documentation a bit<commit_after>
# Migrations

Database migrations are built in in Edmunds using Flask-Migrate.


## Usage

Edmunds has already integrated the db-command in the application's manager.
You can use it as described in the Flask-Migrate-documentation:
```bash
python manage.py db --help
```

Usage of Flask-Migrate documentation:
* [Flask-Migrate](https://flask-migrate.readthedocs.io)

### Models

Models of SQLAlchemy are used by Flask-Migrate to describe your database
structure. Add your model to `app.models` so they are picked up by the
migration-service:
```python
# app/models/mymodel.py

from edmunds.database.model import db, Model

class MyModel(Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(128))
```
Further documentation on how to declare your models can be found here:
* [Flask-SQLAlchemy Models](http://flask-sqlalchemy.pocoo.org/2.2/models/)

> Note: If you want to customize the package where the migrate-service looks
> for models, you can override it in your config:
> ```python
> APP = {
>     'database': {
>         # ...
>         'models': {
>             'my/location/to/the/models',
>             'second/location/to/other/models',
>         },
>     },
> }
> ```
> The described paths are relative to the root-folder of your application.
{'fraction_non_alphanumeric': 0.11649319455564451, 'fraction_numerical': 0.0040032025620496394, 'mean_word_length': 3.423008849557522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1058982', 'n_tokens_mistral': 807, 'n_tokens_neox': 779, 'n_words': 254}