Skip to main content

Offline extensions for alemic database migration framework

Project description

alembic-offline

https://api.travis-ci.org/paylogic/alembic-offline.png https://pypip.in/v/alembic-offline/badge.png https://coveralls.io/repos/paylogic/alembic-offline/badge.svg?branch=master Documentation Status

alembic-offline is an extension for alemic to enrich offline functionality of the migrations

Usage

In your version file:

from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, TIMESTAMP, Column, func
from alembic import op

from alembic_offline import phased, execute_script

from tests.migrations.scripts import script

revision = '1'
down_revision = None


@phased
def upgrade():

    op.create_table(
        'account',
        Column('id', INTEGER, primary_key=True),
        Column('name', VARCHAR(50), nullable=False),
        Column('description', NVARCHAR(200)),
        Column('timestamp', TIMESTAMP, server_default=func.now())
    )
    yield
    op.execute("update account set name='some'")
    yield
    execute_script(script.__file__)


def downgrade():
    pass

Will give the sql output (for sqlite):

-- Running upgrade  -> 1

-- PHASE::0::;

CREATE TABLE account (
    id INTEGER NOT NULL,{space}
    name VARCHAR(50) NOT NULL,{space}
    description NVARCHAR(200),{space}
    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,{space}
    PRIMARY KEY (id)
);

-- PHASE::1::;

update account set name='some';

-- PHASE::2::;

-- SCRIPT::/home/vagrant/workspace/alembic-offline/tests/migrations/scripts/script.pyc::;

INSERT INTO alembic_version (version_num) VALUES ('1');

Contact

If you have questions, bug reports, suggestions, etc. please create an issue on the GitHub project page.

License

This software is licensed under the MIT license

Please refer to the license file

© 2015 Anatoly Bubenkov, Paylogic International and others.

Changelog

1.0.0

  • Initial public release

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

alembic-offline-1.0.0.tar.gz (3.3 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