Reputation: 192
My migration logic includes pretty complex actions like inserting data to just created tables and Stored Procedures creation. If there any way to create/generate proper migration on Symfony 1 using Doctrine 1? The fastest way in my opinion is to create migration with RAW SQL commands I need.
Upvotes: 1
Views: 2178
Reputation: 1025
What I do in these cases is create an empty migration class using the symfony doctrine:generate-migration
command and then fill in both up()
and down()
methods similar to this:
public function up()
{
$dbh = Doctrine_Manager::connection()->getDbh();
$query = "INSERT INTO `some_table` (`id`, `created_at`, `updated_at`)
VALUES
('1', NOW(), NOW()),
('2', NOW(), NOW()),
('3', NOW(), NOW());
";
$stmt = $dbh->prepare($query);
$stmt->execute();
}
Upvotes: 2
Reputation: 35963
You can try this:
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
$results = $connection->execute(" -- YOUR RAW SQL -- ");
Upvotes: 0