Problem with executing INSERT/DELETE/UPDATE during the migration #127

Closed
olegkrivtsov opened this Issue Aug 20, 2013 · 1 comment

Projects

None yet

2 participants

@olegkrivtsov

Hello, I need to execute some inserts/deletions/updates on entities in the database during migrations. I tried to use the connection field of the migration, like below:

public function up(Schema $schema)
{
$this->_connection->insert('user', array(
'login' => 'admin',
'name' => 'Admin',
'password' => crypt('admin'),
'status' => 1,
));
}

But when executing migrations, it prints the error message "No SQL commands found", unless I add this line:

$this->_version->markMigrated();

So, how am I supposed to perform INSERTS/DELETIONS/UPDATES on data during migration of the database?

Thanks for your help.

@stof
Member
stof commented Sep 13, 2013

you should add the SQL to the list of queries being executed instead of executing them directly IMO, by using $this->addSQL()

@stof stof closed this Aug 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment