1. Go to this page and download the library: Download phpixie/migrate library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpixie / migrate example snippets
return array(
// migration configs
'migrations' => array(
'default' => array(
// database connection name
'connection' => 'default',
// migration files path, relative to /assets/migrate/
'path' => 'migrations',
// optional:
// name of the table to keep version data it
'migrationTable' => '__migrate',
// name of the version field in the migration table
'lastMigrationField' => 'lastMigration'
)
),
// seed data configs (we'll cover it later)
'seeds' => array(
'default' => array(
// database connection name
'connection' => 'default',
// seed files path, relative to /assets/migrate
'path' => 'seeds'
)
)
);
framework:database ACTION [ CONFIG ]
Create or drop a database
Arguments:
ACTION Either 'create' or 'drop'
CONFIG Migration configuration name, defaults to 'default'
$this->execute("CREATE TABLE fairies(
id int NOT NULL,
name VARCHAR(255)
)");
$this->message("Output some message to the console");
// Usual Database queries
$this->connection()->updateQuery()
->table('users')
->set(['role' => 'user'])
->execute();
framework:migrate [ CONFIG ]
Run migrations on the database
Arguments:
CONFIG Migration configuration name, defaults to 'default'
framework:seed [ --truncate ] [ CONFIG ]
Seed the database with data
Options:
truncate Truncate the tables before inserting the data.
Arguments:
CONFIG Seed configuration name, defaults to 'default'