GithubHelp home page GithubHelp logo

shayneoneill / peewee_migrate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from klen/peewee_migrate

0.0 2.0 0.0 151 KB

Simple migration engine for Peewee

License: BSD 3-Clause "New" or "Revised" License

Makefile 3.06% Python 96.94%

peewee_migrate's Introduction

Peewee Migrate

Peewee Migrate -- A simple migration engine for Peewee

Build Status

Coverals

Version

Downloads

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 TEXT       Create migrations automatically. Set path to your models module.
    --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.

peewee_migrate's People

Contributors

klen avatar pyup-bot avatar dingus9 avatar proggga avatar koorgoo avatar jjyr avatar lowks avatar kolanos avatar niekbaeten avatar nilsjpwerner avatar tuukkamustonen avatar petrov-vova avatar flother avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.