Download the PHP package iqomp/migrate without Composer

On this page you can find all versions of the php package iqomp/migrate. 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 migrate

iqomp/migrate

Database migration that sync migrate config to database table. This migration method sync your migration config file with what's on database. This migration way is to store the database migration in a file config, and sync the config with your current database state. The migrations logs is not stored on each migration time file or database table, you'll have to check your repository for migrations logs.

The migration is extendable which means one migration is combined with other migration before execution. For example, module post already define structure for table post, another module ( ex: post-publish ) allowed to add column for table post on post-publish migration config.

Installation

Command Line

This module create new hyperf command that can be used to test, create db, sync table and config, and print out sql/script for manual execution by developer.

Migration Config

Update your composer.json file to include content as below:

Then create new file named iqomp/migrate/config.php under you main module directory, fill the file with content as below:

All migrations property is explained as below:

fields

Array list of table fields with name->meta pair, where name is the table column name, and meta is list of column meta data. The column should has at least one property, which is type. Below is list of metas known so far:

comment::string

Column comment, not all database engine accept this actually.

type::string

The column data type, supported data type so far are as below:

  1. Text
    1. CHAR. Require attrs: {length}
    2. ENUM. Require attrs: {options:[]}
    3. LONGTEXT
    4. SET. Require attrs: {options:[]}
    5. TEXT
    6. TINYTEXT
    7. VARCHAR. Require attrs: {length}
  2. Number
    1. BIGINT
    2. BOOLEAN
    3. DECIMAL
    4. DOUBLE. Require attrs: {length}
    5. FLOAT
    6. INTEGER
    7. MEDIUMINT
    8. SMALLINT
    9. TINYINT
  3. Date
    1. DATE
    2. DATETIME
    3. TIMESTAMP
    4. TIME
    5. YEAR

attrs::array

List of additional attributes for the column. Supported attributes for now are:

  1. length::string The length of the column. For DOUBLE it accept comma for length and decimal value.
  2. options::array List of options for the column. Mostly used by ENUM and SET.
  3. null::boolean Set it to false to make sure the column not accept null value
  4. default::mixed Default value for the column.
  5. update::mixed Default value for update action. This attribute use mostly for column updated_at for value CURRENT_TIMESTAMP.
  6. unsigned::boolean Set number column as UNSIGNED, which is not accept negative value.
  7. unique::boolean Set the column as UNIQUE, that don't accept duplicate value.
  8. primary_key::boolean Set the column as primary key.
  9. auto_increment:boolean Set the column as auto increment.

indexes

List of column indexes. It's array name-meta pair where name is the index name and meta is list of index meta data and field list. This property accept properties:

  1. type::string The index type, accepted value are UNIQUE, FULLTEXT, SPATIAL, BTREE, and HASH. If not set, BTREE will be used.
  2. fields::array List of array to use as index columns in format column-options pair. Where column is the column name, and options are list of additional option for the index column. For example, column with type text may have options length for index length.

data

List of data to insert to table on migration if the data is not there yet based on table column. This property is an array column->datalist pair where column is the column name, and datalist is list of row with search-value->row pair where the search-value is the value that will be used on search query to define if the value should be inserted to table or not, while row is column-value pair of new data to insert.

Please note that there's no such update and remove on migration.

Creating Migrator

This part explain how to create new migration handler for some database type.

Create new class that implements interface Iqomp\Migrate\MigratorInterface. The class should has below methods:

public __construct(\Hyperf\Command\Command $cli, array $config)

Construct he class, this method accept arguments command cli database connection config.

public createDb(): bool

Create new database based on provided config on __construct.

public dbExists(): bool

Check if database exists based on provided connection.

public lastError(): ?string

Return last error accured.

public syncTable(string $model, string $table, array $config): void

Sync migration config to database table.

public syncTableTo(string $model, string $table, array $config): void

Sync migration config to database and create print out script/sql for the migration instead of executing it to the database. This action means to be executed manually by developer.

public testTable(string $model, string $table, array $config): void

Compare migration config to database table, and print the comparation result without executing the migration.

Please check iqomp/migrate-mysql for migration example.

After creating the migrator class, register the handler by creating class ConfigProvider on your module to return data as below on class invoke method:

Then update your composer.json file to include content as below:


All versions of migrate with dependencies

PHP Build Version
Package Version
Requires iqomp/model Version ^2.0
hyperf/command Version ^2.1
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 iqomp/migrate contains the following files

Loading the files please wait ....