THINKPHP5 Data Migration (think-migration)

Source: Internet
Author: User

Data Migration Tool (Think-migration) is provided in THINKPHP5, which is the opportunity Phinx Development (document address:http://docs.phinx.org/en/latest/)

One: Configuration think-migration

Add in commond.php

<? PHP return [    "Think\\migration\\command\\migrate\\create",    "Think\\migration\\command\\migrate\\run", "    think\\migration\\command\\migrate\\rollback",    "Think\\migration\\command\\migrate\\status",    " Think\\migration\\command\\seed\\create ",    " Think\\migration\\command\\seed\\run ",];? >

Note that because think-migration is stored in Thinkphp/vendor, vendor should be added to the think in Auoload

require __dir__. ' /.. /thinkphp/vendor/autoload.php ';

Two: command line run

Enter PHP think on the command line to see

Migrate: Database Migration Tool Seed: Database Fill tool

Main discussion Migrate:

Migrate:create: Create a new data migration class, PHP think Migrate:create <file>

forexample:php think migrate:create scproductimage file will generate a PHP file in the development directory

***********************************************************

Migrate:run: Complete Data Migration work PHP think Migrate:run

***********************************************************

Migrate:status: View migrate working status PHP think Migrate:status

***********************************************************************************************

Migrate:rollback: Rollback data to a specified data migration version PHP think Migrate:rollback-t <timeline>

<timeline> is the value of the red box above us

Three: Migrate file preparation

There are three methods in migrate

Up: Executed at Migrate:run (provided there is no change method in the file)

Down: Executed at Migrate:rollback (provided there is no change method in the file)

Change:migrate:run and Migrate:rollback (if the method is present, does not go up and down)

THINKPHP5 Data Migration (think-migration)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.