db-migration
db-migration copied to clipboard
Add method for execute SQL from file
For example, $b->executeSqlFromFile().
Need to come up with a good name. Variants:
loadDump()loadSql()executeSqlFromFile()executeSql()
That could be a bit tricky: https://stackoverflow.com/questions/6346674/pdo-support-for-multiple-queries-pdo-mysql-pdo-mysqlnd/6461110#6461110
It could be implemented in two ways:
- A method accepting a string with many SQL statements. File reading isn't involved and is done with file_get_contents. Not good for huge dumps.
- A method accepting a file path. There we can open a file and seek it till next SQL statement executing previous one. Would be memory efficient but could be a bit slow.
There is execute() method which executes SQL strings.
Name executeFile() looks good for executing SQL files.
The method should be added to CommandInterface and realized in AbstractCommand as execute() method.
After we can add a wrapper to MigrationBuilder
If this functionality is needed, then need to create issue in Yii DB.