Skip to content

Commit

Permalink
docs: Add migrations page, small fixes, Readme notice
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdevita committed Nov 29, 2023
1 parent e4fc95d commit 3651d38
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ An opinionated Discord bot framework inspired by Django and built on
top of [Hikari](https://github.com/hikari-py/hikari), [Tanjun](https://github.com/FasterSpeeding/Tanjun),
[Ormar](https://github.com/collerek/ormar), and [Alembic](https://alembic.sqlalchemy.org/en/latest/).

Atsume is in alpha and breaking changes should be expected. If you have any feedback or advice, feel free
to find me in the [Hikari Discord](https://discord.gg/Jx4cNGG).


## Features

Expand Down
63 changes: 60 additions & 3 deletions docs/atsume_reference/migrations.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,69 @@
# Migrations

## Formatting Migrations
Atsume integrates [Alembic](https://alembic.sqlalchemy.org/en/latest/index.html)
for performing semi-automatic database migrations. A migration is a
database operation that takes us from a previous definition of the
models to the current.

Migrations are automatically formatted if you have the `black` package installed. You can do
:::warning
Atsume's migrations are still under heavy development! While
it can handle many simple tasks fine, it may not always catch
more complicated model modifications. It's a good idea to always
double-check the generated migration files before running them.
:::

## Limitations

Atsume's automatic generation of migrations largely shares the same list of
limitations as Alembic. This notably includes:

- Changes to table, column, or constraint name
- Change of a column's `server_default`

To create migrations for these changes, they must be created manually, which is covered later.

Extending Alembic to add support for automatically generating these changes is
on the roadmap.

## Commands

### Making Migrations

Migrations can be created with the `makemigrations` command.

```shell
python manage.py makemigrations
```

This will make new migrations for any changes in any currently loaded apps.

You can also specify to limit to just a single app.

```shell
python manage.py makemigrations -c my_component
```

### Upgrading and downgrading migrations

You can apply all generated migrations with the `upgrade` command.

```shell
python manage.py upgrade
```

You can also specify a specific app or revision number to upgrade to.

```shell
python manage.py upgrade my_component
```


## Auto-formatting Migrations

Migrations are automatically formatted if you have the `black` package installed.

```shell
pip install black
```

to enable it.

Empty file added docs/atsume_reference/models.md
Empty file.
1 change: 1 addition & 0 deletions docs/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ tutorial_1
tutorial_2
tutorial_3
tutorial_4
tutorial_5
```
2 changes: 1 addition & 1 deletion docs/tutorial/tutorial_4.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Working With The Database
# Database Models and Queries

Atsume integrates the [Ormar](https://collerek.github.io/ormar/) library for handling
database operations. Ormar is an ORM, so it works through defining your
Expand Down
11 changes: 11 additions & 0 deletions docs/tutorial/tutorial_5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Database Migrations

Database migrations are operations that help us transition from a previous
state of the database to a new one. In Atsume, migrations can be automatically
generated as you create and update your database models.

## Adding a foreign key and inspecting the migration

## Renaming a field

## Downgrading

0 comments on commit 3651d38

Please sign in to comment.