Git Product home page Git Product logo

arnold's Introduction

Build Status

#arnold - Migrations for peewee

arnold is a python package to assist in managing migrations for the peewee orm.

A full example application can be viewed at cam-stitt/arnold-example.

##Installation

Installation is simple using pip:

pip install arnold

##Usage

###The arnold_config folder To generate the arnold config folder, run the following command:

arnold init

This will create a directory and fill it with the default content. The directory will look like this:

.
+-- arnold_config
|   +-- __init__.py
|   +-- migrations
|       +-- __init__.py

You can provide an option for a custom folder name by using the --folder option. Note that if you provide a custom folder, you will have to pass the --folder option to all future arnold commands.

###Creating Migrations

Migrations are easy to setup. Simply create a migration folder (with an __init__.py) and then start creating your migrations.

Migrations require two methods. up for creation and down for deletion.

Peewee has the ability to easily perform migrations such as adding a column. See peewee docs.

You must follow the naming convention x_name where x is a number, and name is a name for your personal reference. This will ensure that migrations are run in the correct order. Here is an example of some migration files:

001_initial.py
002_add_admin_to_users.py
003_add_account_table.py

An example of a migration file can be found here.

###Running Migrations

Migrations are run in a stepwise manner. There are two commands available to run migrations in a particular direction. Both of these commands require a number to tell arnold how many migrations you would like to run.

arnold up 1

The above command will run 1 migration upwards, if available.

arnold down 3

The above command will run 3 migrations downwards.

If you pass in a count of 0, arnold will run all migrations that have not yet been run.

arnold up 0

The first time that this is run, the Migration table will be added.

###Status

You can also request the status of the database by running arnold status. It will print the latest migration name and the date that it was completed.

###Configuration

Arnold accepts a number of configuration options to the commands.

  • --folder - The folder to use for configration/migrations.
  • --fake - Add the row to the database without running the migration.

The __init__.py file inside the configuration folder holds the database value. This should be peewee database value. Here is an example __init__.py file:

from peewee import SqliteDatabase

database = SqliteDatabase('test.db')

##Contribute

Ideas or Pull Requests to make this project better are always welcome.

##Support

If you are having issues, please let us know.

##License

The project is licensed under the BSD license.

##Roadmap

At this point, I don't have any items on the roadmap. If you have any ideas, please create an issue.

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.