Hi
Correct me if I’m wrong:
Migrations plugin - allows you to change tables in the database, but you need to know in advance and specify, for example: what columns will be called in the database.
If I do not know in advance how they should be named, I can not dynamically name and create columns in table database.
For example, in my case:
Using data from a third-party API, I need to select the column name and data for these columns from the received JSON, but for my purposes, this plugin is not suitable. I’m right?
If I’m right, can you tell me how to solve this problem?
Or can i do something like this or not?:
<?php
use Migrations\AbstractMigration;
class AdminsController extends AbstractMigration
{
public function change($array_res_api) // array with data from the controller action
{
$table = $this->table('metrica');
foreach($array_res_api as $key => $value){
$table->addColumn($key, 'string', [
'value' => $value,
'limit' => 100,
'null' => false,
]);
}
$table->create();
}
}
Thank you in advance for your cooperation