/**
* Important - modelClass must have a public method "attributeTypes"
* Example:
*
* public function attributeTypes()
* {
* return [
* 'id' => Schema::TYPE_PK,
* 'owner_id' => Schema::TYPE_INTEGER,
* 'name' => Schema::TYPE_STRING,
* 'description' => Schema::TYPE_TEXT,
* 'status' => Schema::TYPE_SMALLINT,
* 'updated_at' => Schema::TYPE_TIMESTAMP,
* 'created_at' => Schema::TYPE_DATETIME,
* ];
* }
*
* Example of use:
*
* (new DbSync([
* 'common\models\', // if namespace equivalent to path
* 'Path to directory' => 'someName\models\',
* ]))->run();
*
*
* @param array $nameSpaces
*/
public function __construct(array $nameSpaces)
{
foreach ($nameSpaces as $key => $nameSpace) {
$this->nameSpaces[$key] = trim($nameSpace, '\\') . '\\';
}
$this->db = \Yii::$app->getDb();
$this->tableNames = $this->db->getSchema()->getTableNames();
}