Skip to main content

Simple tool for managing raw sql migrations scripts.

Project description

https://travis-ci.org/ts-taiye/raw-sql-migrate.svg?branch=master https://coveralls.io/repos/ts-taiye/raw-sql-migrate/badge.svg?branch=master

Goal

Raw-sql-migrate is tool for managing your raw SQL migrations.

Docs

See <http://rsm.readthedocs.org/en/latest/> page for full docs.

TODO

  • Write tests.

  • Make database backend support for Oracle Database.

  • Make base consistency check.

Short guide

  1. Create raw_sql_migrate.yaml in your project dir with next structure:

database:
    engine: engine backend module
    host: database host
    port: database port
    name: database name
    user: user name
    password: user password
history_table_name: migration history table name
  1. Import and make instance of Api:

from raw_sql_migrate.api import Api
api = Api()
  1. Create first migration

api.create('package_a.package_b', name='initial')
  1. Edit migration file found package_a/package_b/migrations/0001_initial.py. Example:

def forward(database_api):
    database_api.execute(
        sql='''
        CREATE TABLE test (
           id INT PRIMARY KEY NOT NULL,
           test_value BIGINT NOT NULL,
        );
        CREATE INDEX test_value_index ON test(test_value);
        ''',
        params={},
        return_result=None,
    )
    database_api.commit()
def backward(database_api):
    database_api.execute(
        sql='''
        DROP TABLE test;
        ''',
        params={},
        return_result=None,
    )
    database_api.commit()
  1. Run migrations:

api.forward('package_a.package_b')
  1. Migrating backwards:

api.backward('package_a.package_b')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raw-sql-migrate-0.1.tar.gz (19.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page