Skip to main content

Simple tool for managing raw sql migrations scripts.

Project description

Status

Latest stable

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

Develop

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

Goal

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

Docs

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

Short guide

  1. Create rsm.yaml or rsm.py 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
RSM_CONFIG = {
    '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,
    'packages': [
        'package_a',
        'package_b',
        'package_c.package_d',
    ],
}
  1. Create first migration
rsm create package_a.package_b initial
  1. Edit migration file found package_a/package_b/migrations/0001_initial.py. Example:
def forward(database_api):
    database_api.execute(
        '''
        CREATE TABLE test (
           id INT PRIMARY KEY NOT NULL,
           test_value BIGINT NOT NULL,
        );
        CREATE INDEX test_value_index ON test(test_value);
        '''
    )

def backward(database_api):
    database_api.execute('DROP TABLE test;')
  1. Run migrations:
rsm migrate package_a.package_b
  1. Migrating backwards:
rsm migrate package_a.package_b 0

Project details


Download files

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

Files for raw-sql-migrate, version 0.3.4
Filename, size File type Python version Upload date Hashes
Filename, size raw-sql-migrate-0.3.4.tar.gz (11.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page