1. Go to this page and download the library: Download erikgreasy/wp-db-migrations 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/ */
// 001_reviewplugin_create_test_table.php
use DbMigrator\Migration;
return new class extends Migration
{
public function up()
{
$tableName = $this->getPrefixedTable('test');
$charset_collate = $this->wpdb->get_charset_collate();
$sql = "CREATE TABLE $tableName (
id int(11) NOT NULL auto_increment,
name varchar(60) NOT NULL,
UNIQUE KEY id (id)
) $charset_collate;";
$this->wpdb->query($sql);
}
};
register_activation_hook(__FILE__, function() {
(new \DbMigrator\Migrator())->migrate();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.