126 lines
3.2 KiB
ReStructuredText
126 lines
3.2 KiB
ReStructuredText
=====
|
|
Alice
|
|
=====
|
|
|
|
.. image:: https://img.shields.io/pypi/v/alice.svg?style=flat
|
|
:target: https://pypi.python.org/pypi/alice
|
|
.. image:: https://img.shields.io/github/license/long2ice/alice
|
|
:target: https://github.com/long2ice/alice
|
|
.. image:: https://github.com/long2ice/alice/workflows/pypi/badge.svg
|
|
:target: https://github.com/long2ice/alice/actions?query=workflow:pypi
|
|
|
|
Introduction
|
|
============
|
|
|
|
Tortoise-ORM is the best asyncio ORM now, but it lacks a database migrations tool like alembic for SQLAlchemy, or Django ORM with it's own migrations tool.
|
|
|
|
This project aim to be a best migrations tool for Tortoise-ORM and which written by one of contributors of Tortoise-ORM.
|
|
|
|
Install
|
|
=======
|
|
|
|
Just install from pypi (**INVALID**):
|
|
|
|
.. code-block:: shell
|
|
|
|
$ pip install alice
|
|
|
|
So bad that pypi project name is used, you can only install from source:
|
|
|
|
.. code-block:: shell
|
|
|
|
$ pip install git+https://github.com/long2ice/alice.git
|
|
|
|
Quick Start
|
|
===========
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice -h
|
|
|
|
Usage: alice [OPTIONS] COMMAND [ARGS]...
|
|
|
|
Options:
|
|
--config TEXT Tortoise-ORM config module, will auto read config dict variable
|
|
from it. [default: settings]
|
|
--tortoise-orm TEXT Tortoise-ORM config dict variable. [default:
|
|
TORTOISE_ORM]
|
|
--location TEXT Migrate store location. [default: ./migrations]
|
|
--app TEXT Tortoise-ORM app name. [default: models]
|
|
-h, --help Show this message and exit.
|
|
|
|
Commands:
|
|
downgrade Downgrade to previous version.
|
|
heads Show current available heads in migrate location.
|
|
history List all migrate items.
|
|
init Init migrate location and generate schema, you must exec first.
|
|
migrate Generate migrate changes file.
|
|
upgrade Upgrade to latest version.
|
|
|
|
Usage
|
|
=====
|
|
|
|
Init schema and migrate location
|
|
--------------------------------
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice --config tests.backends.mysql init
|
|
|
|
Success create migrate location ./migrations/models
|
|
Success init for app "models"
|
|
|
|
Update models and make migrate
|
|
------------------------------
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice --config tests.backends.mysql migrate --name drop_column
|
|
|
|
Success migrate 1_202029051520102929_drop_column.json
|
|
|
|
Format of migrate filename is {version}_{datetime}_{name|update}.json
|
|
|
|
Upgrade to latest version
|
|
-------------------------
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice --config tests.backends.mysql upgrade
|
|
|
|
Success upgrade 1_202029051520102929_drop_column.json
|
|
|
|
Now your db is migrated to latest.
|
|
|
|
Downgrade to previous version
|
|
-----------------------------
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice --config tests.backends.mysql downgrade
|
|
|
|
Success downgrade 1_202029051520102929_drop_column.json
|
|
|
|
Now your db rollback to previous version.
|
|
|
|
Show history
|
|
------------
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice --config tests.backends.mysql history
|
|
|
|
1_202029051520102929_drop_column.json
|
|
|
|
Show heads to be migrated
|
|
-------------------------
|
|
|
|
.. code-block:: shell
|
|
|
|
$ alice --config tests.backends.mysql heads
|
|
|
|
1_202029051520102929_drop_column.json
|
|
|
|
License
|
|
=======
|
|
This project is licensed under the `MIT <https://github.com/long2ice/alice/blob/master/LICENSE>`_ License. |