Migrations for MongoDB based on PHPMongo ODM

Overview

PHPMongo Migrator

Migrations for MongoDB based on PHPMongo ODM

Build Status Daily Downloads Latest Stable Version Coverage Status Gitter

Schema not required in MongoDb, so we dont need to create databases, collections or altering them. However there are some cases when migrations required in schemaless databases:

  • Creating collections with special parameters, like capped collection;
  • Renaming or deleting collections;
  • Creating, renaming or deleting fields;
  • Creating, changing or deleting indexes;

Requirements



Installation

Install locally through composer

composer require sokil/php-mongo-migrator

After installation you will be able to run commands in console by running ./vendor/bin/mongo-migrator command.

Install using phive

phive install sokil/php-mongo-migrator

Compatibility with PHP 7

PHPMongo currently based on old ext-mongo entension. To use this ODM with PHP 7, you need to add compatibility layer, which implement API of old extension over new ext-mongodb. To start using PHPMongo with PHP7, add requirement alcaeus/mongo-php-adapter to composer. Restrictions for using ODM with compatibility layer you can read in known issues of original adapter.

You need to require adapter:

composer require alcaeus/mongo-php-adapter

Usage

$ ./mongo-migrator
Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  create    Create new migration
  help      Displays help for a command
  init      Initialize migrations project
  list      Lists commands
  migrate   Migrate to specific revision of database
  rollback  Rollback to specific version of database
  status    Show status of migrations

Initialisation of migrations

Every command run in project root where composer.json and vendor dir placed. First we need to create new migration project. To do that go to project root and run:

vendor/bin/mongo-migrator init

This creates config file mongo-migrator.yaml and directory "./migrations", where migrations placed. Also you can use php config instead of yaml. Just initialise your project with php config format:

vendor/bin/mongo-migrator init --configFormat=php

You may explicitly define path to conficuration file, and also to migration dir:

vendor/bin/mongo-migrator init --configuration=confins/monfo-migrations.yaml --migrationDir=../migrations/mongo

If migration dir defined relatively, it points to dir where configuration stored. In example above migrations dir will be confins/../migrations/mongo.

Configuration

Configuration format

YAML configuration file placed in file "./mongo-migrator.yaml". PHP has same structure.

default_environment: development

path:
    migrations: migrations
    
environments:
    development:
        dsn: mongodb://localhost
        
        default_database: test
        
        log_database: test
        log_collection: migrations
    
    staging:
        dsn: mongodb://localhost
        
        default_database: test
        
        log_database: test
        log_collection: migrations
    
    production:
        dsn: mongodb://localhost
        
        default_database: test
        
        log_database: test
        log_collection: migrations

Environment is set of configuration parameters, defined for concrete place, like development machine, test or production server.

  • default_environment - some commands required to know environment, where they executed. This parameters defines which environment to use if environment not specified.

  • path.migrations - path to migrations directory, where migration scripts placed.

  • environments - section of environment configs.

Every environment has this parameters:

  • environments.*.dsn - DSN which used to connect to mongo server

  • environments.*.connectOptions - options of MongoClient, described in \MongoClient PHP manual

  • environments.*.default_database - databse, used if no database specified id migration script

  • environments.*.log_database - database, used to store migration log

  • environments..log_collection - collection of database environments..log_database used to store migration log

Environment variables in configuration

Any value may be initialised from environment variable:

default_environment: common

path:
    migrations:  "%env(MONGO_MIGRATIONS_PATH)%"

environments:
    common:
        dsn: "%env(MONGO_DSN)%"
        default_database: "%env(MONGO_DEFAULT_DB)%"
        log_database: "%env(MONGO_LOG_DB)%"
        log_collection: "%env(MONGO_LOG_COLLECTION)%"

Creating new revision

Now you can create your migration script. Creating new revison:

vendor/bin/mongo-migrator create revision_name

Name of revision must be in camel case format. For example run vendor/bin/mongo-migrator create RevisionName. This creates migration script like 20151127093706_RevisionName.php, where "20151127093706" is revision id and "RevisionName" is revision name.

pc:~/php-mongo-migrator$ ./bin/mongo-migrator create RevisionName
New migration created at ~/php-mongo-migrator/migrations/20151127093706_RevisionName.php

Class source is:



class RevisionName extends \Sokil\Mongo\Migrator\AbstractMigration
{
    public function up()
    {
        
    }
    
    public function down()
    {
        
    }
}

Method up() filled with commands executed on migrating process, and down() - on rollback.

Now you can write code for migration and rollback.

Status of migration

If you want to see list of existed revisions with status of migration, run:

vendor/bin/mongo-migrator status [-e|--environment environment=ENVIRONMENT] [-c|--configuration=CONFIGURATION] [-l|--length=LENGTH]

If revision status is "up", revision is applied, otherwise status will be "down".

 Revision        Status  Name            
-----------------------------------       
 20140607165612  down    Test2           
 20140607141237  up      Test1           
 20140607132630  up      RevisionName

Option configuration allows specify path to project configuration, if it differ from default path. Option length allows to limit elements in list.

Migrating and rollback

You can migrate and rollback to any of available revisions. Commands to migrate:

vendor/bin/mongo-migrator migrate  [-r|--revision revision] [-e|--environment environment] [-c|--configuration configuration]

If revision not specified, migration goes to latest revision.

Option configuration allows specify path to project configuration, if it differ from default path.

Command to rollback:

vendor/bin/mongo-migrator rollback [-r|--revision revision] [-e|--environment environment] [-c|--configuration configuration]

If revision not specified, rollback goes to previous revision.

Option configuration allows specify path to project configuration, if it differ from default path.

Writing migration scripts

Databases and collections accessable from migration script through methods AbstractMigration::getDatabase and AbstractMigration::getCollection. Method AbstractMigration::getCollection get's collection of default database, defined in
"environments.*.default_database" parameter of config.

Documentation on database and collection classes may be found in https://github.com/sokil/php-mongo.



class RevisionName extends \Sokil\Mongo\Migrator\AbstractMigration
{
    protected function init() 
    {
        // some common code
    }
    
    public function up()
    {
        $collection = $this
            ->getDatabase('some_database')
            ->getCollection('come_collection');

        // create new field in all documents of collection
        $collection->updateAll(function($operator) {
            $operator->set('newField', 'defaultValue')
        });
    }
    
    public function down()
    {
        $collection = $this
            ->getDatabase('some_database')
            ->getCollection('come_collection');

        // create new field in all documents of collection
        $collection->updateAll(function($operator) {
            $operator->unsetField('newField')
        });
    }
}

Building Phar

  1. Install box using manual at https://github.com/box-project/box2. It must be accessible as box

  2. Check that composer installed and accessible in PATH

  3. You may build phar in three modes: unsigned version, signed by OPENSSH (for self test on run) and signed by GPG (for installation through phive)

3.1) To build unsigned version just run make

make

3.2) To build phar signed with OPENSSH, you need to have own private key. Copy it to ./keys/private.pem or generate new one:

# Generate new one:
openssl genrsa -des3 -out private.pem 4096
# If you want to remove passphrase
openssl rsa -in private.pem -out private.pem
# generate public
openssl rsa -in private.pem -outform PEM -pubout -out public.pem

Then build phar:

make openssh-signed

3.3) To build phar sighen with GPG for phive, you need to place private key to ./keys/private.ask:

gpg --gen-key
gpg --export-secret-keys [email protected] > keys/private.asc

Then build GPG-signed phar:

make gpg-signed

You may verify phar by public key:

" [ultimate] ">
$ gpg --verify mongo-migrator.phar.asc mongo-migrator.phar
gpg: Signature made чт, 22-лис-2018 23:27:46 +0200 EET
gpg:                using RSA key F530929F7ED528F0
gpg:                issuer "[email protected]"
gpg: Good signature from "Dmytro Sokil 
   
    " [ultimate]


   

You may build phars both for legacy and new driver by defining MONGO_DRIVER env variable:

make gpg-signed MONGO_DRIVER=new
make gpg-signed MONGO_DRIVER=legacy

If MONGO_DRIVER env variable not passed, then make will try to detect your driver automatically.

Development

To start development environment in docker run:

./run-docker-cli.sh

To use xdebug, configure your IDE to use port 9001.

There is sandbox to test commands:

cd /phpmongo/tests/
export PHPMONGO_DSN="mongodb://mongodb32"; ../bin/mongo-migrator -vvv status -l 4 -e docker

Unit tests

Local tests:

composer.phar test

Docker tests:

./run-docker-tests.sh
Comments
  • Installation request for symfony/event-dispatcher (locked at v3.2.1) -> satisfiable by symfony/event-dispatcher[v3.2.1]

    Installation request for symfony/event-dispatcher (locked at v3.2.1) -> satisfiable by symfony/event-dispatcher[v3.2.1]

    I was trying to install this repository via composer in an Yii2 project and I got this error:

    `Using version ^0.3.0 for sokil/php-mongo-migrator ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

    Problem 1 - Installation request for sokil/php-mongo-migrator ^0.3.0 -> satisfiable by sokil/php-mongo-migrator[0.3]. - Conclusion: remove symfony/event-dispatcher v3.2.1 - Conclusion: don't install symfony/event-dispatcher v3.2.1 - sokil/php-mongo-migrator 0.3 requires symfony/event-dispatcher 2.* -> satisfiable by symfony/event-dispatcher[2.0.4, 2.0.5, 2.0.6, 2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32, v2.3.33, v2.3.34, v2.3.35, v2.3.36, v2.3.37, v2.3.38, v2.3.39, v2.3.4, v2.3.40, v2.3.41, v2.3.42, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9]. - Can only install one of: symfony/event-dispatcher[v2.7.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.13, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.14, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.15, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.16, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.17, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.18, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.19, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.20, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.21, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.22, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.7.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.13, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.14, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.15, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.8.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[2.0.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[2.0.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[2.0.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[2.0.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.13, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.14, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.15, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.16, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.17, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.18, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.19, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.20, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.21, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.22, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.23, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.24, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.25, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.0.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.13, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.1.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.2.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.13, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.14, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.15, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.16, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.17, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.18, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.19, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.20, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.21, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.22, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.23, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.24, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.25, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.26, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.27, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.28, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.29, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.30, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.31, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.32, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.33, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.34, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.35, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.36, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.37, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.38, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.39, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.40, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.41, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.42, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.3.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.4.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.5.9, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.0, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.1, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.10, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.11, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.12, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.13, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.2, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.3, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.4, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.5, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.6, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.7, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.8, v3.2.1]. - Can only install one of: symfony/event-dispatcher[v2.6.9, v3.2.1]. - Installation request for symfony/event-dispatcher (locked at v3.2.1) -> satisfiable by symfony/event-dispatcher[v3.2.1].

    Installation failed, reverting ./composer.json to its original content. `

    it seems like the migrator is incompatible with symfony/event-dispatcher version 3.x..

    opened by sagarguhe 5
  • Read variables from .env

    Read variables from .env

    Hello guys,

    I was wondering if is possible to load the variables from .env inside .yml config.

    My scenarios is that I have to set twice the same database access, in the.env and .yml.

    Thanks!

    enhancement 
    opened by marabesi 4
  • Configurations option.

    Configurations option.

    Hi i'm not using yaml extension in my framework and it would be nice if people can decide if they want . yaml or simple array. Im comparing migration scripts and i like your setup but would be happy if i don't need to create a .yaml file.

    opened by bobbygrossmann 1
  • Не передается environment для Manager::getDefaultDatabaseName()

    Не передается environment для Manager::getDefaultDatabaseName()

    В файле Sokil\Mongo\Migrator\Manager на 52 строчке не передается environment, из-за чего всегда используется БД по-умолчанию. Фиксится добавлением одной переменной: $this->_client[$environment]->useDatabase($this->_config->getDefaultDatabaseName($environment));

    Слава Украине!

    opened by PavelVesnin 1
  • Add a Gitter chat badge to README.md

    Add a Gitter chat badge to README.md

    opened by gitter-badger 1
  • Allow use environment variables in migration config

    Allow use environment variables in migration config

    Allow use environment valiables in config in format "%env(VARNAME)%":

    default_environment: development
    
    path:
        migrations: migrations
        
    environments:
        development:
            dsn: "%env(MONGODB_DSN)%"
            connectOptions:
              replicaSet: testrs
            default_database: test
            
            log_database: test
            log_collection: migrations
    
    opened by sokil 0
  • Make phar installer througn bash script

    Make phar installer througn bash script

    API to get latest release assets: https://api.github.com/repos/sokil/php-mongo-migrator/releases/latest

    1. Add bash installer
    2. Update manual:

    Install phar

    Run in shell:

    wget http://phpmongokit.github.io/dists/mongo-migrator.phar && chmod +x mongo-migrator.phar && sudo mv mongo-migrator.phar /usr/local/bin
    
    opened by sokil 0
  • Migrate reset

    Migrate reset

    Is there a way to reset all the migrations created in the database?

    The readme says that is possible to rollback to a specific version, but what I wouldm like to do is to reset all the migrations and execute them again.

    opened by marabesi 3
  • Migration order

    Migration order

    • User1 create migration 111111_mogration1
    • User2 create migration 222222_mogration2
    • User2 apply migration 222222_mogration2
    • Can user User1 still apply it's migration?
    opened by sokil 0
Releases(1.0.2)
Owner
Sokil
Kyiv, Ukraine
Sokil
Php mongodb admin, use new mongodb extension.

EasyMongo EasyMongo is a Mongodb web management application. This project is based on iwind/RockMongo, uses the latest mongodb-extension + mongo-php-l

Meng Wang 8 Oct 31, 2022
Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

Laravel Migrations Generator Generate Laravel Migrations from an existing database, including indexes and foreign keys! Upgrading to Laravel 5.4 Pleas

Bernhard Breytenbach 3.3k Dec 30, 2022
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Laravel MongoDB This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library ex

Jens Segers 6.3k Jan 5, 2023
MongoDB PHP library

MongoDB PHP Library This library provides a high-level abstraction around the lower-level PHP driver (mongodb extension). While the extension provides

mongodb 1.5k Dec 31, 2022
Simple MongoDB API for PHP!

SimpleMongo SimpleMongo is a simple API for MongoDB, written in PHP. How to use? First of all, copy SimpleMongo.php into your project and fill the fir

AlicanCopur 9 Jul 19, 2021
Eloquent MongoDB Repository Implementation

Eloquent MongoDB Repository Eloquent MongoDB Repository using nilportugues/repository as foundation, using jenssegers/mongodb. Installation Use Compos

Nil Portugués Calderó 18 Feb 12, 2022
RockMongo is a MongoDB administration tool, written in PHP 5.

Introduction -------------------------------------- RockMongo is a MongoDB administration tool, written in PHP 5, very easy to install and use. Inst

Liu Xiangchao 1k Dec 27, 2022
MongoDB ORM that includes support for references,embed and multilevel inheritance.

Introduction Features Requirements Installation Setup Database Basic Usage - CRUD Relationship - Reference Relationship - Embed Collection Inheritance

Michael Gan 202 Nov 17, 2022
Extend Jenssegers/laravel-mongodb to support transaction function

Laravel Mongodb (Transactional support) Introduction Jensseger's laravel-mongodb extension package is very popular among Laravel developers, but it la

Iman RJ 10 Nov 1, 2022
PHP Database Migrations for Everyone

Phinx: Simple PHP Database Migrations Intro Phinx makes it ridiculously easy to manage the database migrations for your PHP app. In less than 5 minute

CakePHP 4.3k Jan 7, 2023
Extract SQL statements from migrations

This is my package MigrationToSql To install: composer require bcleverly/migrationtosql --dev This repo is here to help you extract the SQL queries fr

Ben 4 Apr 15, 2022
Convention-based Object-Relational Mapper

Corma Corma is a high-performance, convention-based ORM based on Doctrine DBAL. Corma is great because: No complex and difficult to verify annotations

Michael O'Connell 30 Dec 20, 2022
A Redis based, fully automated and scalable database cache layer for Laravel

Lada Cache A Redis based, fully automated and scalable database cache layer for Laravel Contributors wanted! Have a look at the open issues and send m

Matt 501 Dec 30, 2022
A simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure)

my little forum my little forum is a simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure).

Mark Hoschek 97 Dec 29, 2022
Laravel Code Generator based on MySQL Database

Laravel Code Generator Do you have a well structed database and you want to make a Laravel Application on top of it. By using this tools you can gener

Tuhin Bepari 311 Dec 28, 2022
Pure PHP NoSQL database with no dependency. Flat file, JSON based document database.

Please give it a Star if you like the project ?? ❤️ SleekDB - A NoSQL Database made using PHP Full documentation: https://sleekdb.github.io/ SleekDB i

Kazi Mehedi Hasan 745 Jan 7, 2023
Tiny php mysql lib (PDO-based) with handy fetch/update functionality, supports both SQL and parametric queries

Micro PHP mysql lib (~ 200 lines of code) with ultra powerful CRUD for faster than ever development: parametric fetch/insert/update/delete (based on a

Mr Crypster 18 Dec 10, 2022
phpSleekDBAdmin - a web-based SleekDB database admin tool written in PHP

phpSleekDBAdmin is a web-based SleekDB database admin tool written in PHP. Following in the spirit of the flat-file system used by SleekDB, phpSleekDBAdmin consists of a single source file, phpsleekdbadmin.php. The interface and user experience is comparable to that of phpLiteAdmin and phpMyAdmin.

GalAnonym 8 Oct 26, 2022
MongoDB ODM. Part of @PHPMongoKit

PHPMongo ODM PHP ODM for MongoDB. ⭐ Why to use this ODM? You can easily work with document data through comfortable getters and setters instead of arr

Sokil 240 Nov 27, 2022
Psalm Stubs for doctrine/mongodb-odm library

doctrine-mongodb-psalm-plugin A Doctrine plugin for Psalm (requires Psalm v4). Installation: $ composer require --dev runtothefather/doctrine-mongodb-

Evgeny 6 Jun 15, 2022