{ "info": { "author": "Anatoly Bubenkov, Paylogic International and others", "author_email": "developers@paylogic.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Other Environment", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4" ], "description": "alembic-offline\n===============\n\n.. image:: https://api.travis-ci.org/paylogic/alembic-offline.png\n :target: https://travis-ci.org/paylogic/alembic-offline\n\n.. image:: https://pypip.in/v/alembic-offline/badge.png\n :target: https://crate.io/packages/alembic-offline/\n\n.. image:: https://coveralls.io/repos/paylogic/alembic-offline/badge.svg?branch=master\n :target: https://coveralls.io/r/paylogic/alembic-offline?branch=master\n\n.. image:: https://readthedocs.org/projects/alembic-offline/badge/?version=latest\n :alt: Documentation Status\n :scale: 100%\n :target: https://readthedocs.org/projects/alembic-offline/\n\nalembic-offline is an extension for alemic to enrich offline functionality of the migrations\n\n.. contents::\n\nUsage\n-----\n\nPhased migrations\n^^^^^^^^^^^^^^^^^\n\nalembic-offline introduces a helper which allows to implement phased migrations, e.g. those which steps\nare divided into logical phases. For example, you can have steps to be executed before code deploy and\nthose after.\n\nIn your alembic config file (main section):\n\n::\n\n phases = before-deploy after-deploy final\n default-phase = after-deploy\n\nIn your version file:\n\n.. code-block:: python\n\n from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, TIMESTAMP, Column, func\n from alembic import op\n\n from alembic_offline import phased, execute_script\n\n from tests.migrations.scripts import script\n\n revision = '1'\n down_revision = None\n\n\n @phased\n def upgrade():\n\n op.create_table(\n 'account',\n Column('id', INTEGER, primary_key=True),\n Column('name', VARCHAR(50), nullable=False),\n Column('description', NVARCHAR(200)),\n Column('timestamp', TIMESTAMP, server_default=func.now())\n )\n yield\n op.execute(\"update account set name='some'\")\n yield\n execute_script(script.__file__)\n\n\n def downgrade():\n pass\n\nWill give the sql output (for sqlite):\n\n.. code-block:: sql\n\n -- Running upgrade -> 1\n\n -- PHASE::before-deploy::;\n\n CREATE TABLE account (\n id INTEGER NOT NULL,\n name VARCHAR(50) NOT NULL,\n description NVARCHAR(200),\n timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (id)\n );\n\n -- PHASE::after-deploy::;\n\n update account set name='some';\n\n -- PHASE::final::;\n\n -- SCRIPT::scripts/script.py::;\n\n INSERT INTO alembic_version (version_num) VALUES ('1');\n\nAs you see, phases are rendered as SQL comments to divide migration steps, so those who execute migration\ncan see which phase's step it is.\nHowever, if migration procedure is highly customized, you can use alembic-offline API described below.\n`get_migration_data` returns migration phases in special form so you can automate their execution.\n\nArbitrary script as operation\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nFor complex migrations, it's not enough to execute sql, you might need some script to be executed instead.\nFor that, there's special operation:\n\n.. code-block:: python\n\n from alembic_offline import execute_script\n\n def upgrade():\n execute_script('scripts/script.py')\n\nIf you'll get migration sql, it will be rendered as SQL comment:\n\n.. code-block:: sql\n\n -- SCRIPT::scripts/script.py::;\n\nFor those who execute migrations it will be visible and they can execute the script manually.\nHowever, if migration procedure is highly customized, you can use alembic-offline API described below.\n`get_migration_data` returns script migration steps in special form so you can automate their execution.\nFor online mode, the script will be executed as subprocess via python `subprocess` module.\n\nGet migration data\n^^^^^^^^^^^^^^^^^^\n\nalembic-offline provides specialized API to get certain migration data as dictionary:\n\n.. code-block:: python\n\n from alembic_offline import get_migration_data\n\n from alemic.config import Config\n\n config = Config('path to alemic.ini')\n\n data = get_migration_data(config, 'your-revision')\n\n assert data == {\n 'revision': 'your-revision',\n 'phases': {\n 'after-deploy': [\n {\n 'type': 'mysql',\n 'script': 'alter table account add column name VARCHAR(255)'\n },\n {\n 'type': 'python',\n 'script': 'from app.models import Session, Account; Session.add(Account()); Session.commit()',\n 'path': 'scripts/my_script.py'\n },\n ]\n }\n }\n\n`get_migration_data` requires both `phases` and `default-phase` configuration options to be set.\n`default-phase` is needed to be able to get migration data even for simple migrations without phases.\n\nGet migration data in batch\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nalembic-offline provides an API call to get migration data for all revisions:\n\n.. code-block:: python\n\n from alembic_offline import get_migrations_data\n\n from alemic.config import Config\n\n config = Config('path to alemic.ini')\n\n data = get_migrations_data(config)\n\n assert data == [\n {\n 'revision': 'your-revision',\n 'phases': {\n 'after-deploy': [\n {\n 'type': 'mysql',\n 'script': 'alter table account add column name VARCHAR(255)'\n },\n {\n 'type': 'python',\n 'script': 'from app.models import Session, Account; Session.add(Account()); Session.commit()',\n 'path': 'scripts/my_script.py'\n },\n ]\n }\n }\n ]\n\nCommand line utilities\n^^^^^^^^^^^^^^^^^^^^^^\n\nBecause with alembic revisions it's sometimes hard to find which the correct down revision should be; especially\nwhen there are multiple heads we added the alembic-offline graph command.\n\nThe graph command will generate a `dot file `_ of\nthe revisions, this file can then be converted to an image for easy visualization.\n\nUsage:\n\n::\n\n alembic-offline graph --filename revisions.dot --alembic-config path/to/alembic.ini\n\nThen if you have `graphviz `_ installed you can run:\n\n::\n\n dot -Tpng -o revisions.png revisions.dot\n\nTo generate a png image.\n\nContact\n-------\n\nIf you have questions, bug reports, suggestions, etc. please create an issue on\nthe `GitHub project page `_.\n\nLicense\n-------\n\nThis software is licensed under the `MIT license `_\n\nPlease refer to the `license file `_\n\n\u00a9 2015 Anatoly Bubenkov, Paylogic International and others.\n\nChangelog\n=========\n\n1.2.0\n-----\n\n* add migration dependency tree generation command (hvdklauw)\n\n1.1.0\n-----\n\n* add down_revision to migration data (bubenkoff)\n* reverse migration order to simplify the application (bubenkoff)\n\n1.0.5\n-----\n\n* correctly handle multi-phased migration data extraction (bubenkoff)\n\n1.0.4\n-----\n\n* online script execution implemented (bubenkoff)\n* `get_migrations_data` API (bubenkoff)\n\n1.0.3\n-----\n\n* Added arbitrary script operation (bubenkoff)\n* Strict phases configuration assertions for phased migration decorator (bubenkoff)\n* `get_migration_data` API (bubenkoff)\n\n1.0.0\n-----\n\n* Initial public release (bubenkoff)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/paylogic/alembic-offline", "keywords": null, "license": "MIT license", "maintainer": null, "maintainer_email": null, "name": "alembic-offline", "package_url": "https://pypi.org/project/alembic-offline/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/alembic-offline/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/paylogic/alembic-offline" }, "release_url": "https://pypi.org/project/alembic-offline/1.2.0/", "requires_dist": null, "requires_python": null, "summary": "Offline extensions for alemic database migration framework", "version": "1.2.0" }, "last_serial": 1697825, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "55a09e64e75f8a419c287b4ac972c151", "sha256": "133b3d00a8a299acc8760923107897316608f14f2b78323c2079638e01cb9ea9" }, "downloads": -1, "filename": "alembic-offline-1.0.0.tar.gz", "has_sig": false, "md5_digest": "55a09e64e75f8a419c287b4ac972c151", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3340, "upload_time": "2015-04-25T01:02:35", "url": "https://files.pythonhosted.org/packages/3f/59/cd7c80362720bddba0b825fb02fcdf7719a49929b597af4f197720ea6f97/alembic-offline-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d571079b7f8d40840b9ee398ec791d12", "sha256": "3b888e2d1f03bc909a93d39ffd799a02734a671b222413c13f4c5df8d1e42cac" }, "downloads": -1, "filename": "alembic-offline-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d571079b7f8d40840b9ee398ec791d12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5950, "upload_time": "2015-04-27T08:25:50", "url": "https://files.pythonhosted.org/packages/ef/f4/cf243b10816e0b3fd14aa61a1faf0925f4da23b2239a369c988e82e6a9a5/alembic-offline-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "aa86dd5783d4901262b272d3475aeda6", "sha256": "90c35fd05066637cb22094163392b60a80606a32f97b3938dcb48d0f1765d779" }, "downloads": -1, "filename": "alembic-offline-1.0.2.tar.gz", "has_sig": false, "md5_digest": "aa86dd5783d4901262b272d3475aeda6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5945, "upload_time": "2015-04-27T08:50:49", "url": "https://files.pythonhosted.org/packages/42/07/5dc12f3832c7ea8b749338abc7626fa5c4a5d15ef22da634d66c7095d8c4/alembic-offline-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "94059f57c62df227864d988199e90346", "sha256": "38f7ba2d7388f863c210185748dc448372f129e98cc0cfb3c92f3f14b0d4f389" }, "downloads": -1, "filename": "alembic-offline-1.0.3.tar.gz", "has_sig": false, "md5_digest": "94059f57c62df227864d988199e90346", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6004, "upload_time": "2015-04-27T21:50:56", "url": "https://files.pythonhosted.org/packages/e3/f1/1dfa5e28644088124fe3f139948ebc840f291c0839ce8c524abfc765f6b4/alembic-offline-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "77d63131ac11531d190c730e2d41d27e", "sha256": "d4d604833aa71b7f2cd0512a13a95a2cd56b562c58ff23338a2e5924589e89d8" }, "downloads": -1, "filename": "alembic-offline-1.0.4.tar.gz", "has_sig": false, "md5_digest": "77d63131ac11531d190c730e2d41d27e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6587, "upload_time": "2015-04-28T15:54:19", "url": "https://files.pythonhosted.org/packages/24/22/07cdbfc348a17ab63f6eefb55087e81fc480536164ac9aaa49951787d0de/alembic-offline-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "82e7e452c83aeff3c3210b65bab29b94", "sha256": "88711dd738d237487d036829b54c4bdb50f35afdb681161045c36c5073a38459" }, "downloads": -1, "filename": "alembic-offline-1.0.5.tar.gz", "has_sig": false, "md5_digest": "82e7e452c83aeff3c3210b65bab29b94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6620, "upload_time": "2015-05-04T14:16:24", "url": "https://files.pythonhosted.org/packages/81/6d/69a690e115ec8e1778b42b6352351bde67010b799fada70c27b85306242d/alembic-offline-1.0.5.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "7cf2032bbdd6e186a2ae295f076f4e73", "sha256": "4847aff46185f1ace2725310e9605fb1176bd7c65e9200baf3edfd0ee00cc277" }, "downloads": -1, "filename": "alembic-offline-1.1.0.tar.gz", "has_sig": false, "md5_digest": "7cf2032bbdd6e186a2ae295f076f4e73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6795, "upload_time": "2015-06-03T00:14:44", "url": "https://files.pythonhosted.org/packages/6a/26/d3506b9d12aca4a8ff7d66525628fab3cb6541c1f025b0404c94395a4a45/alembic-offline-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "b40fbf19182a2268d20b6fa462be6dfc", "sha256": "6f689d90666a8ecec79a8daffb228c1221c9448da2ce47029030ab03afd23b4e" }, "downloads": -1, "filename": "alembic-offline-1.2.0.tar.gz", "has_sig": false, "md5_digest": "b40fbf19182a2268d20b6fa462be6dfc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8098, "upload_time": "2015-08-28T10:12:29", "url": "https://files.pythonhosted.org/packages/6d/bb/4f31eaf23fa45ec4b0b29b76e0c040c4a7e8d8d0c3e5281767a9ad602ce0/alembic-offline-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b40fbf19182a2268d20b6fa462be6dfc", "sha256": "6f689d90666a8ecec79a8daffb228c1221c9448da2ce47029030ab03afd23b4e" }, "downloads": -1, "filename": "alembic-offline-1.2.0.tar.gz", "has_sig": false, "md5_digest": "b40fbf19182a2268d20b6fa462be6dfc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8098, "upload_time": "2015-08-28T10:12:29", "url": "https://files.pythonhosted.org/packages/6d/bb/4f31eaf23fa45ec4b0b29b76e0c040c4a7e8d8d0c3e5281767a9ad602ce0/alembic-offline-1.2.0.tar.gz" } ] }