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.
2 Answers
2
votes
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();
}