<commit_before>Mongrate
========

[![Build Status](https://travis-ci.org/amyboyd/mongrate.svg?branch=master)](https://travis-ci.org/amyboyd/mongrate)

A command-line tool for applying migrations to a MongoDB database. Migrations are non-linear, and can be tested by writing simple YML files.

Doctrine's [Mongo abstraction layer](https://github.com/doctrine/mongodb) is used to provide a clean database API. Mongrate does *not* use Doctrine's Mongo ODM - this is to avoid having to write mapping classes and to make it very quick to write migrations.

At the moment, Mongrate does not support applying migrations to multiple databases.

Example migrations can be found in `resources/examples/`.

Symfony 2 users can use [MongrateBundle](https://github.com/amyboyd/mongrate-bundle) to integrate easily with a Symfony 2 project.

Installation
============

Mongrate is available [via Composer](https://packagist.org/packages/amyboyd/mongrate).

Once you have downloaded Mongrate, run these commands:

    php composer.phar install
    chmod a+x mongrate
    cp config/parameters.yml.dist config/parameters.yml

Edit `config/parameters.yml` and enter your MongoDB connection information.

Usage
=====

To generate a migration file, with the name "UpdateAddressStructure":

    ./mongrate generate-migration UpdateAddressStructure

To list available migrations:

    ./mongrate list-migrations

To toggle a migration (useful while writing your migration):

    ./mongrate toggle 20140523_UpdateAddressStructure

To migrate up or down:

    ./mongrate up 20140523_UpdateAddressStructure

    ./mongrate down 20140523_UpdateAddressStructure

To verify a migration with it's YML test files:

    ./mongrate test 20140523_UpdateAddressStructure (up|down|empty)

Contributing
============

Please submit pull requests [on GitHub](https://github.com/amyboyd/mongrate/pulls).

Install [PHP-CS-Fixer](https://github.com/fabpot/PHP-CS-Fixer):

    sudo curl http://get.sensiolabs.org/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixer

Install the Git pre-commit hook:

    ln -s ../../resources/pre-commit .git/hooks/pre-commit
    chmod a+x .git/hooks/pre-commit

To run the test suite, just run `phpunit`. The tests use a database called `mongrate_test` in your local MongoDB server.
<commit_msg>Update Readme.<commit_after>Mongrate
========

[![Build Status](https://travis-ci.org/amyboyd/mongrate.svg?branch=master)](https://travis-ci.org/amyboyd/mongrate)

A command-line tool for applying migrations to a MongoDB database. Migrations are non-linear, and can be tested by writing simple YML files.

Doctrine's [Mongo abstraction layer](https://github.com/doctrine/mongodb) is used to provide a clean database API. Mongrate does *not* use Doctrine's Mongo ODM - this is to avoid having to write mapping classes and to make it very quick to write migrations.

At the moment, Mongrate does not support applying migrations to multiple databases.

Example migrations can be found in `resources/examples/`.

Symfony 2 users can use [MongrateBundle](https://github.com/amyboyd/mongrate-bundle) to integrate easily with a Symfony 2 project.

Installation
============

Mongrate is available [via Composer](https://packagist.org/packages/amyboyd/mongrate).

Once you have downloaded Mongrate, run these commands:

```sh
php composer.phar install
chmod a+x mongrate
cp config/parameters.yml.dist config/parameters.yml
```

Edit `config/parameters.yml` and enter your MongoDB connection information.

Usage
=====

To generate a migration file, with the name "UpdateAddressStructure":

```
./mongrate generate-migration UpdateAddressStructure
```sh

To list available migrations:

```sh
./mongrate list-migrations
```

To toggle a migration (useful while writing your migration):

```sh
./mongrate toggle 20140523_UpdateAddressStructure
```

To migrate up or down:

```sh
./mongrate up 20140523_UpdateAddressStructure
```

```sh
./mongrate down 20140523_UpdateAddressStructure
```

To verify a migration with it's YML test files:
```sh
./mongrate test 20140523_UpdateAddressStructure (up|down|empty)
```

Contributing
============

Please submit pull requests [on GitHub](https://github.com/amyboyd/mongrate/pulls).

Project follow PSR2 standard. 

When you do `composer install` it should set a `git-precomit` to help you follow the standards.

Install the Git pre-commit hook manually:

```sh
bash contrib/setup.sh
```

To run the test suite, just run `phpunit`. The tests use a database called `mongrate_test` in your local MongoDB server.

{'fraction_non_alphanumeric': 0.10459973463069439, 'fraction_numerical': 0.01525873507297656, 'mean_word_length': 4.667919799498747, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5463591', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1295, 'n_words': 472}