graviton / migrationkit
A console application to generate migrations for Graviton based services
Requires
- php: >=7.1.0
- skyscanner/jsonpath: ^0.7.3
Requires (Dev)
- cypresslab/gitelephant: ^1.1
- diff/diff: ^2.1
- fzaninotto/faker: ^1.6
- libgraviton/codesniffer: ^2.0
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.0
- symfony/console: ^3.3
- symfony/filesystem: ^3.3
- symfony/finder: ^3.3
- twig/twig: ^1.34
This package is auto-updated.
Last update: 2024-09-17 20:33:12 UTC
README
This is a Symfony Console application that provides utilities in regard to generation and migration of Graviton based services and service definitions.
When we generate migrations, we generate classes that can be used with doesntmattr/mongodb-migrations
.
Current state
This is a fairly new project and generation migrations is no simple matter.
migrationkit
has been designed in an extendable way, so we can add new migration scenarios rather easily.
Usage
The recommended way to use this is by using our docker image. It is available on Docker Hub, so you can use it right away.
Docker
You can execute the tool quite easily:
docker run --rm graviton/migrationkit
You should see the help screen with the list of commands.
To execute a given command, just add it to the run
:
docker run --rm graviton/migrationkit graviton:migrations:generate --help
Feel free to wrap this with Docker Compose.
Solving user permissions problems
Our Docker Image comes with some support for solving user permission problems as it shall generate resources on your local disk.
The image has the environment variables PUID
and PGID
that you should set to the UID and GID of
your local user
that owns the target directories.
You can locate the UID and GID by issuing the id
command:
user@host:~$ id
uid=1000(user) gid=1000(user) groups=1000(user),...
Once you know that, set those on the run
:
docker run --rm -e PUID=1000 -e PGID=1000 graviton/migrationkit graviton:migrations:generate --help
This should resolve all permission problems.
Composer
If you really want to use this in a project context, you can use composer:
composer require --dev graviton/migrationkit
This really should be a dev
dependency for your project.
Commands
graviton:version-migrations:generate
Generate migrations from your current branch to another branch and generate migrations
Assumes that the directory passed as baseDir
is a git repository. It then copies
that directory, switches to the tag/branch defined by argument branch
and
calls the command graviton:migrations:generate
with those two directory,
thus allowing you to generate differences between two (possibly unpushed) branches.
One would pull develop
, create a feature branch, make his changes and then
call this command with develop
as a compare branch.
graviton:fixture-entity:generate
Generate random JSON payload entities according to a service definition.
This is a helper command for general work on migrations. It takes a service
definition and generates number
(argument) files (default 10) of random fake
JSON payloads that can be PUT
ed/POST
ed to a Graviton instance.
They conform to the specified service definition and include all specified fields.
Please note that these fake data payloads may make no sense to an application that wants to understand/do business stuff out of the structures.
The refMap
file
In order to generate valid extref
fields, you may have to specify an refMap
file
(option --refMap
to the command).
This is a simple YAML file that maps the Collection
attribute in the field to an URL.
Example:
App: /core/app/ MyOtherEntity: /other/entity/
graviton:definition-metadata:generate
Generates YML metadata files from service definitions
Internally, migrationkit
uses simple YAML files to do stuff. This command helps
to generate those files. You need those files for example for the
graviton:fixture-entity:generate
command.
graviton:from-ios-schema:generate
Generate service definitions from the iOS Schema
This fills a specific need for people that want to generate Graviton compatible service definitions from a proprietary iOS Schema format.
graviton:migrations:generate
Lower level migration command that allows you to specify two directories and migrate between them.
Allows you to specify two directories and generate migrations from them. It will prompt you for possible conflicts and you may need to provide input to resolve them.