PHP code example of activecollab / databasemigrations

1. Go to this page and download the library: Download activecollab/databasemigrations 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/ */

    

activecollab / databasemigrations example snippets




namespace Acme\App\Migrations;

use ActiveCollab\DatabaseMigrations\Migration\Migration;

class AddUserRolesTable extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function up()
    {
    }
}



namespace Acme\App\Migrations;

use ActiveCollab\DatabaseMigrations\Migration\MigrationInterface;

class AddUserRolesTable implements MigrationInterface
{
    …
}



namespace Acme\App\Migrations;

use ActiveCollab\DatabaseMigrations\Migration\Migration;

class AddUserRolesTable extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function up()
    {
        if (!in_array('user_roles', $this->connection->getTableNames()) {
            $this->logger->debug('{table} not found in the database', ['table' => 'user_roles']);
            $thos->connection->execute('CREATE TABLE STATEMENT');
            $this->logger->debug('{table} created', ['table' => 'user_roles']);
        }
    }
}