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.
Asked
Active
Viewed 1,769 times
2 Answers
2
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();
}

Kris Peeling
- 1,025
- 8
- 18
0
You can try this:
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
$results = $connection->execute(" -- YOUR RAW SQL -- ");

Alessandro Minoccheri
- 35,521
- 22
- 122
- 171