peewee-migrate-dev 0.0.1a0

Last updated:

0 purchases

peewee-migrate-dev 0.0.1a0 Image
peewee-migrate-dev 0.0.1a0 Images
Add to Cart

Description:

peeweemigratedev 0.0.1a0

Peewee Migrate – A simple migration engine for Peewee




Contents

Requirements

Dependency Note


Installation
Usage

From shell
From python
Migration files


Bug tracker
Contributing
Contributors
License



Requirements

python 2.7,3.5
peewee >= 3.3.1


Dependency Note
For Peewee<3.0 please use Peewee-Migrate==0.14.0.



Installation
Peewee Migrate should be installed using pip:
pip install peewee_migrate


Usage
Do you want Flask integration? Look at Flask-PW.

From shell
Getting help:
$ pw_migrate --help

Usage: pw_migrate [OPTIONS] COMMAND [ARGS]...

Options:
--help Show this message and exit.

Commands:
create Create migration.
migrate Run migrations.
rollback Rollback migration.
Create migration:
$ pw_migrate create --help

Usage: pw_migrate create [OPTIONS] NAME

Create migration.

Options:
--auto FLAG Scan sources and create db migrations automatically. Supports autodiscovery.
--auto-source TEXT Set to python module path for changes autoscan (e.g. 'package.models'). Current directory will be recursively scanned by default.
--database TEXT Database connection
--directory TEXT Directory where migrations are stored
-v, --verbose
--help Show this message and exit.
Run migrations:
$ pw_migrate migrate --help

Usage: pw_migrate migrate [OPTIONS]

Run migrations.

Options:
--name TEXT Select migration
--database TEXT Database connection
--directory TEXT Directory where migrations are stored
-v, --verbose
--help Show this message and exit.


From python
from peewee_migrate import Router
from peewee import SqliteDatabase

router = Router(SqliteDatabase('test.db'))

# Create migration
router.create('migration_name')

# Run migration/migrations
router.run('migration_name')

# Run all unapplied migrations
router.run()


Migration files
By default, migration files are looked up in os.getcwd()/migrations directory, but custom directory can be given.
Migration files are sorted and applied in ascending order per their filename.
Each migration file must specify migrate() function and may specify rollback() function:
def migrate(migrator, database, fake=False, **kwargs):
pass

def rollback(migrator, database, fake=False, **kwargs):
pass



Bug tracker
If you have any suggestions, bug reports or
annoyances please report them to the issue tracker
at https://github.com/klen/peewee_migrate/issues


Contributing
Development of starter happens at github: https://github.com/klen/peewee_migrate


Contributors
See AUTHORS.rst


License
Licensed under a BSD license.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.