Download the PHP package whirlwind-framework/mongo-migrations without Composer
On this page you can find all versions of the php package whirlwind-framework/mongo-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whirlwind-framework/mongo-migrations
More information about whirlwind-framework/mongo-migrations
Files in whirlwind-framework/mongo-migrations
Package mongo-migrations
Short Description MongoDB migration tool implementation for Whirlwind framework
License BSD-3-Clause
Informations about the package mongo-migrations
Mongo migrations
MongoDB's migration tool
Implementation notes
-
Bind MigrationPaths dependencies (paths to all your migration folders).
-
In case of using your own migration template file you have to bind
Config
dependency. - Register
MongoMigrationServiceProvider
for your console application.
Commands
After registering MongoMigrationServiceProvider
you have ability to manage your database migrations by console commands.
Create migration
Run this command for creating new migration file.
The command require migration file name as the first argument. If you would like to specify migration path you can use option
--path=/my/migration/path
. Pay attention that such path must be registered in MigrationPaths
dependency.
Install migration
The command will help you to install migrations.
You can control amount of migration that will be installed in your system by the limitation with the first argument. The value must be integer >= 0. By default, all migrations are installed.
Rollback migration
Rollback command helps to cancel changes made by migrations
The last migration will be rollback in case of running the command without arguments. You can specify amount of migrations
for rollback by specifying limit with the first argument. Option --all
will help you to rollback all migrations.
Status
If you would like to see which migrations have run thus far, you may use the migrate:status
command
The output will show you 10 last migrations that was applied. You can specify limit with the first argument or with
the option --all
.
Migration API
Migration
has a set of useful methods for managing migration process.
create($collection, $callback)
- used for creating new collection. Incallback
you can specify additional options that will be used during creation.createIfNotExists($collection, $callback)
- works ascreate
, but in case of collection existence it skips creationmodify($collection, $callback)
- used for modifying collection. Incallback
you can specify additional options and make extra operations such as renaming collection or creating new indexes. Pay attention if you require different options for different commands usemodify
method as much as need.drop($collection)
- delete the whole collectiondropIfExists($collection)
- same asdelete
, but checks if the collection exist.Blueprint Methods
create(callable)
- used for configuring creation process.setCapped(bool)
- setcapped
option.setSize(int)
- setsize
option for capped collection.setValidator(array)
- setvalidator
option for collection.setValidationLevel(string)
- setvalidatorLevel
option for collection. Possible values areBlueprint::VALIDATION_LEVEL_OFF
Blueprint::VALIDATION_LEVEL_STRICT
,Blueprint::VALIDATION_LEVEL_MODERATE
.setValidationAction(string)
- setvalidationAction
option for collection. Possible values areBlueprint::VALIDATION_ACTION_WARN
,Blueprint::VALIDATION_ACTION_ERROR
.setCollation(array)
- setcollatiob
option for collection. Check MongoDB official documentation for more information.setOption(string, mixed)
- set any option by its name.drop()
- remove the whole collection.dropIfExists()
- remove the whole collection if it exists.createIfNotExists(callable)
- configure creation process for collection if it is not exists.createIndex(array, ?string)
- create new index forkeys
withname
.dropIndex(string)
- delete index by name.dropAllIndexes()
- delete all collection indexes.renameCollection(string)
- rename collection.insert(array)
- insert new document.batchInsert(array)
- insert multiple documents.update(array, array)
- update documents by criteria with new data.delete(array)
- delete documents by criteria.
All versions of mongo-migrations with dependencies
whirlwind-framework/migration-core Version *
whirlwind-framework/persistence-mongodb Version dev-main
league/container Version ~4.0