bueue/oracle-migrations-bundle
Installation Run:
composer require bueue/oracle-migrations-bundle
Ensure your project uses Symfony 2.x (last release: 2017) and Doctrine Migrations Bundle.
Enable the Bundle
Register in app/AppKernel.php:
new Bueue\OracleMigrationsBundle\BueueOracleMigrationsBundle(),
Configure Oracle DBAL
Add driver_class to your config.yml under doctrine.dbal.connections.default:
driver_class: Bueue\OracleMigrationsBundle\Driver\OracleDriver
First Migration Generate and run a migration as usual:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
Doctrine\DBAL\Driver\OCI8\Connection with a custom driver optimized for Oracle migrations.Migration Generation
doctrine:migrations:diff to generate migrations with Oracle-specific optimizations.Batch Processing
// src/DocRoot/Migrations/VersionYYYYMMDDHMS.php
public function up(Schema $schema)
{
$this->addSql('ALTER TABLE large_table MOVE PARTITION p1');
// Use Oracle-specific syntax for performance
}
Transaction Management
$connection->beginTransaction();
try {
$connection->executeStatement('CREATE TABLE ...');
$connection->commit();
} catch (\Exception $e) {
$connection->rollBack();
throw $e;
}
doctrine/doctrine-migrations-bundle installed (composer require doctrine/doctrine-migrations-bundle).doctrine:schema:update --dump-sql to preview SQL before migration.Bueue\OracleMigrationsBundle\Migration\OracleAwareMigration for Oracle-specific logic.Deprecated Symfony Version
Oracle-Specific SQL Limitations
LIMIT/OFFSET in INSERT). Use Oracle equivalents like ROWNUM:
$this->addSql('INSERT INTO table SELECT * FROM source WHERE ROWNUM <= 1000');
Connection Handling
oci8 driver. Ensure no other part of the app manually instantiates OCI8Connection without the custom driver.Migration Locking
SET TRANSACTION READ WRITE or NOWAIT clauses:
$this->addSql('ALTER TABLE table LOCK NOWAIT');
Enable SQL Logging
Add to config.yml:
doctrine:
dbal:
logging: true
logging_format: '%%SQL%% %%TIME%%'
Check logs for Oracle-specific errors (e.g., ORA-01756 for unsupported syntax).
Check Driver Registration Verify the custom driver is loaded:
php bin/console debug:container bueue_oracle_migrations.driver
Custom Driver Logic
Extend Bueue\OracleMigrationsBundle\Driver\OracleDriver to add Oracle-specific features (e.g., parallel DDL execution).
Migration Pre/Post Hooks
Override Bueue\OracleMigrationsBundle\Migration\OracleAwareMigration to add pre-migration checks:
protected function preUp(Schema $schema)
{
if (!$this->connection->getDatabasePlatform()->supports('ORACLE_FEATURE')) {
throw new \RuntimeException('Unsupported Oracle feature');
}
}
Batch Size Configuration Configure batch sizes in migrations for large operations:
# config.yml
bueue_oracle_migrations:
batch_size: 5000 # Default batch size for INSERT/UPDATE
How can I help you explore Laravel packages today?