3 use Phinx\Migration\AbstractMigration;
 
   10     public function up() {
 
   12         if (!$this->hasTable(
'groups_entity') || !$this->hasTable(
'metadata')) {
 
   16         $prefix = $this->getAdapter()->getOption(
'table_prefix');
 
   17         $cols = [
'name', 
'description'];
 
   18         $col_names = 
"'" . implode(
"', '", $cols) . 
"'";
 
   20         $groups_query = 
"SELECT * FROM {$prefix}groups_entity LIMIT 100";
 
   21         while (
$rows = $this->fetchAll($groups_query)) {
 
   23             foreach (
$rows as $row) {
 
   31                 DELETE FROM {$prefix}metadata 
   32                 WHERE entity_guid IN ({$guids}) AND 
   33                 name IN ({$col_names}) 
   36             $new_metadata_rows = [];
 
   38             foreach (
$rows as $row) {
 
   39                 foreach ($cols as $col) {
 
   45                     $new_metadata_rows[] = [
 
   46                         'entity_guid' => $row[
'guid'],
 
   49                         'value_type' => 
'text',
 
   52                         'time_created' => time(),
 
   58             if (!empty($new_metadata_rows)) {
 
   59                 $this->table(
'metadata')->insert($new_metadata_rows)->saveData();
 
   64                 DELETE FROM {$prefix}groups_entity 
   65                 WHERE guid IN ({$guids}) 
   70         $this->table(
'groups_entity')->drop()->save();
 
$guids
Activates all specified installed and inactive plugins.
up()
Move groups_entity attributes to metadata.