Metadata-Version: 2.1
Name: mongrations
Version: 0.0.2
Summary: MongoDB Migrations for Python 3.5+
Home-page: https://github.com/ableinc/mongrations
Author: AbleInc - Jaylen Douglas
Author-email: douglas.jaylen@gmail.com
License: UNKNOWN
Description: # Mongrations
        ![alt text](https://img.icons8.com/ios/50/000000/database-restore.png "Mongrations Logo")
        A migrations tool for Python 3.5+. Mongrations started as a MongoDB migrations tool but has introduced MySQL & Postgres
        as compatible servers for the Mongrations tool.
        
        # Steps
        1 . Generate a migration file
        ```bash
        mongrations -C true --name insert-into-members
        ```
        2 . Contents of the generated migration file (*import and class definition are 
        autogenerated for migration file* - **contents of up() and down() are user defined**.)
        ```python
        from mongrations import Mongrations, ClassType
        
        
        class Mongration:
            def __init__(self):
                pass
        
            @staticmethod
            def up(db: ClassType):
                collection = db['members']
                data = {
                    'accountId': 1,
                    'username': 'admin',
                    'email': 'admin@able.digital',
                    'firstName': 'Site',
                    'lastName': 'Owner'
                }
                collection.insert_one(data)
        
            @staticmethod
            def down(db: ClassType):
                collection = db['members']
                collection.delete_one({'username': 'admin'})
        
        
        Mongrations(Mongration, 'sync')
        ```
        3 . Run migrations
        ```bash
        mongrations -M true
        ```
        
        # Install
        ```bash
        pip install --upgrade mongrations
        ```
        or install locally
        ```bash
        python setup.py build
        sudo python setup.py install
        ```
        
        # Use
        Mongrations comes with a CLI Tool as well as a class for a pythonic migration approach. PyMongo, PyMySQL & Psycopg2 are used under
        the hood, so follow <a href="https://api.mongodb.com/python/current/tutorial.html#getting-a-collection">PyMongo</a>'s,
        <a href="https://github.com/PyMySQL/PyMySQL">PyMySQL</a>'s, or <a href="https://github.com/psycopg/psycopg2">Psycopg2</a>'s documentation 
        for instructions on how to create your migrations. For the environment variable tool used in this application, follow 
        <a href='https://github.com/ableinc/pydotenvs'>this repo</a> (its also installed with this package).
        
        **CLI**
        ```bash
        Usage: mongrations [OPTIONS]
        
        Options:
          -M, --migrate BOOLEAN  Run migrations
          -C, --create BOOLEAN   Create new migration
          -N, --name TEXT        Name for newly created migration
          -F, --file_path TEXT   File path for newly created migration
          -U, --undo BOOLEAN     Undo last migration
          -D, --down BOOLEAN     Revert database
          --version              Show the version and exit.
          --help                 Show this message and exit.
        ```
        **CLI Examples**
        ```bash
        mongrations -C true --name [migration_name]  # create new migration
        mongrations -M true  # run migrations
        mongrations -D true  # tear down migrations
        mongrations -U true  # undo last migration
        ```
        
        **Mongrations Class**
        ```python
        from mongrations import MongrationsCli
        
        migrations = MongrationsCli()
        
        migrations.create(file_path='file/path', name='file_name')
        migrations.migrate()
        migrations.down()
        migrations.undo()
        ```
        Run example migration in examples/ folder
        
        # Issues
        Please report all issues to repo.
        
        # Notes
        You can install psycopg2 from source via setup.py develop build or refer to their repo.
Keywords: migrations,python3,automation,database,json,nosql,python,database tool,automation tool,open source,mongodb,mysql,postgres,sql
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
