$ git clone https://github.com/kenzo0107/phinx-mysql $ cd phinx-mysql
Create and Run Containers of Phinx, DB (MySQL).
1
$ make build
1 2 3 4 5 6
$ docker-compose ps
Name Command State Ports ------------------------------------------------------------------------- phinxmysql_db-migrate_1 phinx --help Exit 0 phinxmysql_db_1 docker-entrypoint.sh mysqld Up 3306/tcp
The Container db-migrate is used as for one-off container, so its state is Exit 0.
Initialize Phinx Project
Phinx creates a default file called phinx.yml.
1
$ make init
In default setting, phinx select development environment.
1. Create Table
Create phinx definition file
1 2 3 4 5 6
$ make create DB=hogehoge CLASS=CreateTableUsers $ make create DB=mogemoge CLASS=CreateTableMembers ... ... created db/migrations/hogehoge/20170724065658_create_table_users.php created db/migrations/mogemoge/20170724065738_create_table_members.php
classCreateTableUsersextendsAbstractMigration { publicfunctionup() { // Automatically generated id is excluded, and primary key is set as user_id $t = $this->table('users', ['id' => 'user_id']);
mysql> use mogemoge mysql> show full columns from members; +-------------+-------------+-----------------+------+-----+-------------------+----------------+---------------------------------+-----------------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------------+-------------+-----------------+------+-----+-------------------+----------------+---------------------------------+-----------------+ | id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | | | member_code | varchar(20) | utf8_general_ci | NO | UNI | NULL | | select,insert,update,references | 会員コード | | created | timestamp | NULL | NO | | CURRENT_TIMESTAMP | | select,insert,update,references | | | updated | datetime | NULL | YES | | NULL | | select,insert,update,references | | +-------------+-------------+-----------------+------+-----+-------------------+----------------+---------------------------------+-----------------+
Rollback
1
$ make rollback
3. Create sample seeds for Multi Databases;
Create phinx definition file
1 2 3 4 5 6
$ make seed_create DB=hogehoge CLASS=UserSeeder $ make seed_create DB=mogemoge CLASS=MembersSeeder ... ... created ./db/seeds/hogehoge/UsersSeeder.php created ./db/seeds/mogemoge/MembersSeeder.php
The command chkconfig is no longer available in Ubuntu. The equivalent command to chkconfig is update-rc.d. This command nearly supports all the new versions of ubuntu.
Software Collections give you the power to build, install, and use multiple versions of software on the same system, without affecting system-wide installed packages.