Download the PHP package semisedlak/migratte without Composer

On this page you can find all versions of the php package semisedlak/migratte. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package migratte

Migratte

Migratte is simple SQL migrations management standalone CLI app, framework-agnostic. It is inspired by Phinx, but it is much simpler, and it doesn't require CakePHP framework to be installed.

You can install it using composer:

How it works

It is controlled by (Symfony Console) CLI commands for:

  1. generate new migration
  2. commit migration
  3. rollback migration
  4. showing migrations status
  5. showing configuration info

Migration anatomy

Migrations are simple rollback) SQL queries with additional metadata all together.

💡 Migratte doesn't provide (yet) rich migrations management. It is just a simple tool for executing your SQL queries and it is up to you to write them. You can use any SQL query you want.

You can still use Phinx with CakePHP Migrations for migrations management. I recommend Adminer for database management.

Specific migration class extends from basic migration class. It contains timestamp in file name and class name witch should not be modified.

Migration file that doesn't contain down() method is "breakpoint", that means rollback cannot be performed. BUT! There is an option --force to perform rollback with this kind of migration.

This tool creates it's "memory" in same database as migrations target. It uses dibi database layer for connection and queries executions.

You can use it with:

Configuration

You can override this default configuration options:

providing options array as first argument of Application::boot() method from executable file. You can read how to set up connection in dibi documentation.

Executable file

Create a file bin/migrations in the root dir of your project with following content:

Don't forget to change permission using chmod +x bin/migrations

Commands

When you run bin/migrations in CLI you will see "help" overview with possible commands.

💡 Hint: You can use --help (or -h) option for each command to see more details.

migratte:generate

Command generates new migration file which then can be modified. You can specify migration name as first argument. Write it as normal sentence, it will be converted to desired form automatically.

This will generate file database/migrations/20190101_120000-create-users-table.php with following content:

⚠️ Warning! Don't modify migration class name. Don't modify file name after it was committed. You can modify up() and down() methods to contain your SQL queries.

If you want to change migration name you can change it in getName() method. It is used only for displaying purposes.

Then copy your SQL queries to up() and down() methods. If down() method returns NULL or FALSE it is considered as "breakpoint" migration (it cannot be rollbacked because it doesn't provide "down" operation).

Example migration

migratte:commit

Command commits (runs) new migrations. By default, it will run all non-committed migrations one-by-one. You can specify less to commit with limit (first) argument:

But there is more. You can specify datetime limits --from and --to for limiting committing.

Are you unsure what migrations will be committed? Use --dry-run (or -d) option to see what migrations will be committed without actually committing them.

Migratte automatically put migrations into groups. These groups are simply integer numbers and they are important for rollback strategy. You can't specify group number. It will be automatically incremented. If you use default rollback strategy (by commit date) it will rollback migrations from the last group (with highest number) in reverse order of committing.

migratte:rollback

Command performs rollback operation to already committed migrations back to previous state. Rollback will be done only on (by default) migrations from latest group. You can specify more migrations to rollback with limit (first) argument:

In this case, it will ignore groups and rollback last 3 committed migrations.

If migration doesn't contain down() method or this method simply returns NULL or FALSE it is considered as "breakpoint". Calling rollback on "breakpoint" will throw an error. This can be bypassed by using --force (or -f) option.

Rollback strategy

You can specify rollback strategy by using --strategy option. There are currently three strategies for rollback:

  1. by commit "date" (this is default) (--strategy=date) - rollback by commit date (migrations from last group will be rollbacked by commit date in reverse order of committing)
  2. by migration "order" (--strategy=order) - rollback migrations by migrations order (if you sort files by name, you will get migrations order, so last committed file will be rollbacked first)
  3. by specific "file" (--strategy=file) - rollback specific migration file. You have to provide migration file name (without path) as --file option. Hint: you can omit .php extension.

migratte:status

Command shows current migrations' status (what is or isn't committed, which migration is breakpoint and more).

There is also an option --compact (or -c) to show compact table of migrations.

migratte:info

Command shows current Migratte configuration.

Are you using Nette framework?

Great! You can use Nette DI extension to register a Migratte panel into Tracy (something like migratte:status and migratte:info combined but... in HTML... with styles). It will use dibi extension for connection definition.

Changelog

0.4.0

Please update your bin/migrations executable file Application class namespace like this:


All versions of migratte with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
dibi/dibi Version ^4 || ^5
symfony/console Version ^4 || ^5 || ^6
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package semisedlak/migratte contains the following files

Loading the files please wait ....