/PHP_Migration

Simple and Effective migration for Wordpress and Core php

Primary LanguagePHPMIT LicenseMIT

PHP Migration

Simple PHP package for Database Migration, with zero dependancy.

Packagist Release Wordpresss License

For Wordpress Migration

include_once('/wordpress/migration.php');

$my_table_schema =  [
          'student_meta' => [
             'id' => [                  // Result : "id int(20) auto_increment primary key"
                 'key' => [
                     'auto_increment',
                     'primary key'
                 ],
                 'type' => 'int',
                 'limit' => 20
             ],
             'name' => [                // Result : "name varchar(255) unique key"
                 'key' => [
                     'unique key'
                 ],
                 'type' => 'varchar',
                 'limit' => 255
             ],
             'value' => [               // Result : "value longtext"
                 'key' => [],
                 'type' => 'longtext',
                 'limit' => ''
             ],
              '__table_property' => [    // For Table Properties.
                'ENGINE' => 'InnoDB'
            ]
           ]
          ];

For Core PHP

  $my_table_schema = [
        'student' => [
            'student_id' => 'integer',
            'name' => 'string',
            'class' => 'string',
            'dob'  => 'data',
            'age' => 'integer'
        ],
        'class' => [
            'class_id' => 'integer',
            'student_id' => 'integer',
            'section' => 'string'
        ]
     ];

Finally


$table_schema = "YOUR_TABLE_SCHEMA" ($my_table_schema)

// Trigger Migration.
ST_DATABASE::migrate($table_schema);     // It's Generate Formatted MySQL Query and Execute.

It will creates the table Student and Class with given properties.

License

MIT License © Shankar Thiyagaraajan