Code Monkey home page Code Monkey logo

pyway's Introduction

Pyway Database Version Control

Overview

Pyway is a database versioning and migration tool inspired by Flyway

Download and Install

To install use pip:

$ pip install pyway

Or clone the repo:

$ git clone https://github.com/jasondcamp/pyway.git
$ python setup.py install

Configuration

Pyway environment variables and command line options

Priority is env variables -> config file -> command args

Env Variable Command Line Description Default
PYWAY_DATABASE_MIGRATION_DIR --database-migration-dir Folder name to migration files resources
PYWAY_SQL_MIGRATION_PREFIX Prefix for version in migration file V
PYWAY_SQL_MIGRATION_SEPARATOR Separator between version and description to the migration file __
PYWAY_SQL_MIGRATION_SUFFIXES Suffix extension for migration files .sql
PYWAY_TABLE --database-table Name of schema history table public.pyway
PYWAY_TYPE --database-type Data Base Management System [postgres, mysql ] required
PYWAY_DATABASE_HOST --database-host Host to connect to the database localhost
PYWAY_DATABASE_PORT --database-port Port to connect to the database 5432
PYWAY_DATABASE_NAME --database-name Name of database to connect postgres
PYWAY_DATABASE_USERNAME --database-username User to use to connect to the database postgres
PYWAY_DATABASE_PASSWORD --database-password Password to use to connect to the database None
PYWAY_CONFIG_FILE -c, --config Configuration file .pyway.conf
--schema-file Used when importing a schema file

Configuration file

Pyway supports a configuration file with the default file as .pyway.conf. A sample config file is below:

database_type: postgres
database_username: postgres
database_password: 123456
database_host: localhost
database_port: 5432
database_database: postgres
general:
database_migration_dir: schema
datbase_table: public.pyway

Pyway Files

Files are raw SQL files that are named like the following:

V{major}_{minor}__{description}.sql

Example: V01_01__initial_schema.sql

Note that the description needs to match the word regexp [A-Za-z0-9_]

Usage

Info

Information lets you know where you are. At first glance, you will see which migrations have already been applied, which others are still pending, and whether there is a discrepancy between the checksum of the local file and the database schema table.

$ pyway info

Validate

Validate helps you verify that the migrations applied to the database match the ones available locally. This compares the checksums to validate that what is in the migration on disk is what was committed into the database.

$ pyway validate

Migrate

After validate, it will scan the Database migration dir for available migrations. It will compare them to the migrations that have been applied to the database. If any new migration is found, it will migrate the database to close the gap.

$ pyway migrate

Import

This allows the user to import a schema file into the migration, for example if the base schema has already been applied, then the user can import that file in so they can then apply subsequent migrations.

$ pyway import --schema-file V01_01__initial_schema.sql

pyway's People

Contributors

jasondcamp avatar wviana 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.