Metadata-Version: 2.0
Name: dbschema
Version: 1.0.2
Summary: Schema migration made easy
Home-page: https://github.com/gabfl/dbschema
Author: Gabriel Bordeaux
Author-email: pypi@gab.lc
License: MIT
Platform: UNKNOWN
Classifier: Topic :: Database
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python
Classifier: Development Status :: 4 - Beta
Requires-Dist: PyYAML
Requires-Dist: argparse
Requires-Dist: psycopg2
Requires-Dist: pymysql

dbschema
========

``dbschema`` is a tool to run MySQL or PostgreSQL migrations
automatically. Using a table, it keeps a state of previous migrations to
avoid duplicates.

Features:

-  Support for MySQL and PostgreSQL
-  Optional pre and post-migration queries (for example to update
   privileges)
-  Multiple migrations in multiple databases can be processed as one.

Installation
------------

Install ``dbschema``
~~~~~~~~~~~~~~~~~~~~

.. code:: bash

    pip3 install dbschema

Create a config file
~~~~~~~~~~~~~~~~~~~~

Create the file ``~/.dbschema.yml`` and add your databases
configuration. `See example <dbschema_sample.yml>`__

Create migrations table
~~~~~~~~~~~~~~~~~~~~~~~

``dbschema`` uses a table called ``migrations_applied`` to keep track of
migrations already applied to avoid duplication. See the schema for
`MySQL <schema/mysql.sql>`__ or `PostgreSQL <schema/postgresql.sql>`__.

Migrations folder structure
---------------------------

For each database, you need to have a migration path (setting ``path``
in the migration file).

Within that path you need to create one folder per migration. This
folder needs to contain a file called ``up.sql`` with the SQL queries.

::

    /path/to/migrations/db1/
    |-- migration1/
    |   |-- up.sql
    |-- migration2/
    |   |-- up.sql
    |...
    /path/to/migrations/db2/
    |-- migration1/
    |   |-- up.sql
    |-- migration2/
    |   |-- up.sql
    |...

Usage
-----

.. code:: bash

    dbschema

    # or
    dbschema --config /path/to/config.yml


