|
| 1 | +--- |
| 2 | +title: "Oracle to PostgreSQL Application Conversion: Best Practices" |
| 3 | +description: Best practices and recommendations for optimal Oracle to PostgreSQL application conversion using Visual Studio Code PostgreSQL extension. |
| 4 | +author: shriram-muthukrishnan |
| 5 | +ms.author: shriramm |
| 6 | +ms.reviewer: maghan |
| 7 | +ms.date: 04/15/2026 |
| 8 | +ms.service: azure-database-postgresql |
| 9 | +ms.topic: concept-article |
| 10 | +ms.collection: |
| 11 | + - ce-skilling-ai-copilot |
| 12 | +--- |
| 13 | + |
| 14 | +# Best practices for converting Oracle application code to Azure Database for PostgreSQL (Preview) |
| 15 | + |
| 16 | +This article provides best practices and recommendations to ensure optimal results when using the Oracle to Azure Database for PostgreSQL application conversion feature in Visual Studio Code. |
| 17 | + |
| 18 | +## Quick start: essential practices |
| 19 | + |
| 20 | +**Most critical for success**: |
| 21 | +1. **Complete schema conversion first**: Improves conversion accuracy through Coding Notes and type mapping context. |
| 22 | +1. **Select a code-centric AI model**: Use Claude Sonnet 4.6, Claude Opus 4.6, or a similar model such as GPT-5.2-Codex. |
| 23 | +1. **Connect to your deployed PostgreSQL database**: Provides accurate object references during conversion. |
| 24 | +1. **Let the agent complete its TODO list without interruption**: Ensures a complete and consistent conversion. |
| 25 | +1. **Test converted code thoroughly**: Manual validation is essential to catch semantic differences. |
| 26 | + |
| 27 | +## Assess your Oracle integration level |
| 28 | + |
| 29 | +All projects follow the same conversion process, but your Oracle integration level determines where to focus your preparation and validation efforts. |
| 30 | + |
| 31 | +### Standard Oracle usage |
| 32 | + |
| 33 | +**Your application primarily uses**: |
| 34 | +- Standard JDBC/ODBC connections |
| 35 | +- Basic SQL operations (SELECT, INSERT, UPDATE, DELETE) |
| 36 | +- Common frameworks (Spring, Hibernate, Entity Framework) |
| 37 | +- Standard data types (VARCHAR, INTEGER, DATE) |
| 38 | + |
| 39 | +**Preparation emphasis**: Focus on schema conversion and AI model setup |
| 40 | +**Validation emphasis**: Automated testing and basic connectivity verification |
| 41 | +**Risk level**: Low - conversion typically succeeds with standard practices |
| 42 | + |
| 43 | +### Moderate Oracle integration |
| 44 | + |
| 45 | +Requires careful validation. |
| 46 | +**Your application includes**: |
| 47 | +- Some Oracle-specific SQL (CONNECT BY, PIVOT, outer join syntax) |
| 48 | +- Basic PL/SQL procedure calls |
| 49 | +- Oracle data types (CLOB, BLOB, NUMBER with precision) |
| 50 | +- Framework-specific Oracle configurations |
| 51 | + |
| 52 | +**Preparation emphasis**: Thorough dependency identification and incremental conversion approach |
| 53 | +**Validation emphasis**: Manual review of converted SQL and extensive integration testing |
| 54 | +**Risk level**: Medium - expect some manual fixes and thorough testing required |
| 55 | + |
| 56 | +### Heavy Oracle integration |
| 57 | + |
| 58 | +Requires a migration strategy. |
| 59 | +**Your application heavily uses**: |
| 60 | +- Oracle-specific APIs (Advanced Queuing, Spatial, Text Search) |
| 61 | +- Complex PL/SQL with business logic |
| 62 | +- Oracle system packages (DBMS_*, UTL_*) |
| 63 | +- Oracle enterprise features (TAF, FCF, VPD) |
| 64 | + |
| 65 | +**Preparation emphasis**: Review [Oracle to Azure Database for PostgreSQL application conversion limitations (Preview)](app-conversions-limitations.md) for manual replacement strategies |
| 66 | +**Validation emphasis**: Architecture review and comprehensive testing strategy |
| 67 | +**Risk level**: High - significant manual work and potential architecture changes required |
| 68 | + |
| 69 | +> [!IMPORTANT] |
| 70 | +> Regardless of integration level, all projects require thorough testing and validation before production deployment. The conversion tool accelerates migration but doesn't replace proper testing practices. |
| 71 | +
|
| 72 | +## Pre-conversion preparation |
| 73 | + |
| 74 | +Proper preparation before starting application conversion significantly improves conversion accuracy and reduces manual intervention requirements. |
| 75 | + |
| 76 | +### Complete schema conversion first |
| 77 | + |
| 78 | +While not strictly required, completing schema conversion before application conversion provides significant benefits: |
| 79 | + |
| 80 | +- **Coding Notes availability**: Schema conversion generates Coding Notes that provide context for application conversion |
| 81 | +- **Database context**: The conversion tool can read your converted schema for accurate object references |
| 82 | +- **Type mapping accuracy**: Application code conversions align with actual database type mappings |
| 83 | +- **Reduced errors**: Fewer mismatches between application code and database objects |
| 84 | + |
| 85 | +### Organize your codebase |
| 86 | + |
| 87 | +- **Clean structure**: Organize files logically before importing into the migration project |
| 88 | +- **Remove unnecessary files**: Exclude files that don't contain Oracle database dependencies |
| 89 | +- **Backup originals**: Keep a complete backup of original source code before conversion |
| 90 | +- **Version control**: Ensure your codebase is under version control before starting |
| 91 | + |
| 92 | +## AI model configuration |
| 93 | + |
| 94 | +Proper configuration of GitHub Copilot Agent Mode is critical for high-quality application conversion. |
| 95 | + |
| 96 | +### Model selection requirements |
| 97 | + |
| 98 | +- **Required model**: Claude Sonnet 4.6 or Claude Opus 4.6 or higher. |
| 99 | +- **Verification**: Confirm model selection in GitHub Copilot chat interface before starting conversion |
| 100 | +- **Consistency**: Use the same model throughout the conversion process |
| 101 | + |
| 102 | +### Agent Mode optimization |
| 103 | + |
| 104 | +- **Single conversion session**: Complete one application conversion project at a time |
| 105 | +- **Avoid interruptions**: Let the agent complete its TODO list without interruption |
| 106 | +- **Monitor progress**: Watch for any prompts or questions that require input |
| 107 | + |
| 108 | +## Database context configuration |
| 109 | + |
| 110 | +Proper database configuration ensures the conversion tool has accurate context for code transformation. |
| 111 | + |
| 112 | +### PostgreSQL connection setup |
| 113 | + |
| 114 | +Before running application conversion, ensure: |
| 115 | + |
| 116 | +- Your Azure Database for PostgreSQL connection is configured in the PostgreSQL extension |
| 117 | +- The connection is tested and working |
| 118 | +- You have read access to the schema objects |
| 119 | + |
| 120 | +### Database selection |
| 121 | + |
| 122 | +When prompted to select a database during conversion: |
| 123 | + |
| 124 | +- Choose the database where your converted DDL is deployed |
| 125 | +- Ensure the selected database contains all referenced objects |
| 126 | + |
| 127 | +### Connection privileges |
| 128 | + |
| 129 | +The PostgreSQL account used for application conversion should have: |
| 130 | + |
| 131 | +| Privilege | Purpose | |
| 132 | +| --- | --- | |
| 133 | +| `CONNECT` | Connect to the database | |
| 134 | +| `SELECT` on tables | Read schema and table information | |
| 135 | +| `SELECT` on views | Access view definitions | |
| 136 | +| `USAGE` on schemas | Access schema objects | |
| 137 | + |
| 138 | +## Conversion execution best practices |
| 139 | + |
| 140 | +Follow these practices during the conversion process for optimal results. |
| 141 | + |
| 142 | +### Project structure |
| 143 | + |
| 144 | +Maintain project structure: |
| 145 | + |
| 146 | +```output |
| 147 | +.github/postgres-migration/project_name/ |
| 148 | +├── application_code/ |
| 149 | +│ └── your_codebase/ |
| 150 | +├── coding_notes/ |
| 151 | +└── reports/ |
| 152 | +``` |
| 153 | + |
| 154 | +### File organization |
| 155 | + |
| 156 | +- **Logical grouping**: Organize files by module or feature |
| 157 | +- **Clear naming**: Use descriptive folder names |
| 158 | +- **Flat when possible**: Avoid deeply nested structures that complicate navigation |
| 159 | + |
| 160 | +### Conversion monitoring |
| 161 | + |
| 162 | +During conversion: |
| 163 | + |
| 164 | +- **Watch the TODO list**: Monitor as Agent Mode works through tasks |
| 165 | +- **Note any errors**: Document any errors or warnings that appear |
| 166 | +- **Don't interrupt**: Allow the process to complete fully |
| 167 | +- **Review incrementally**: Check converted files as they're completed |
| 168 | + |
| 169 | +## Success indicators |
| 170 | + |
| 171 | +**You're on track if**: |
| 172 | +- Conversion completes without errors |
| 173 | +- Generated TODO list has clear sequence of items (typically around 10 items) |
| 174 | +- Database connectivity works immediately |
| 175 | +- Unit tests pass with minimal fixes |
| 176 | +- No Oracle-specific import errors |
| 177 | + |
| 178 | +**Red flags requiring attention**: |
| 179 | +- Many Oracle-specific errors during conversion |
| 180 | +- Connection failures after conversion |
| 181 | +- Extensive manual code changes needed |
| 182 | +- Performance degradation in converted queries |
| 183 | + |
| 184 | +## Critical validation strategy |
| 185 | + |
| 186 | +Although automated conversion accelerates migration, manual validation is essential to catch semantic differences, platform-specific behaviors, and edge cases that AI might miss. |
| 187 | + |
| 188 | +### High priority |
| 189 | + |
| 190 | +#### Database connectivity |
| 191 | + |
| 192 | +- Verify connection string formats for PostgreSQL |
| 193 | +- Test connection pooling configurations |
| 194 | +- Validate timeout and retry settings |
| 195 | + |
| 196 | +#### SQL query conversions |
| 197 | + |
| 198 | +- Review converted query syntax for correctness |
| 199 | +- Test queries that use complex Oracle-specific features (CONNECT BY, PIVOT) |
| 200 | +- Validate parameter binding and placeholder syntax |
| 201 | + |
| 202 | +#### Data type handling |
| 203 | + |
| 204 | +- Verify type conversions in application logic (NUMBER, DATE precision) |
| 205 | +- Test date/time handling code (Oracle vs PostgreSQL differences) |
| 206 | +- Validate numeric precision handling |
| 207 | + |
| 208 | +### Medium priority |
| 209 | + |
| 210 | +#### Stored procedure calls |
| 211 | + |
| 212 | +- Review procedure and function call syntax |
| 213 | +- Validate parameter passing (REF CURSOR, OUT parameters) |
| 214 | +- Test return value handling and exception management |
| 215 | + |
| 216 | +#### Framework configurations |
| 217 | + |
| 218 | +- Verify ORM dialect changes (Hibernate, Entity Framework) |
| 219 | +- Test connection pool settings in application servers |
| 220 | +- Validate transaction management configurations |
| 221 | + |
| 222 | +### Lower priority |
| 223 | + |
| 224 | +#### Performance and optimization |
| 225 | + |
| 226 | +- Query performance compared to Oracle |
| 227 | +- Indexing strategy effectiveness |
| 228 | +- Connection pool sizing |
| 229 | + |
| 230 | +### Validation process |
| 231 | + |
| 232 | +- **Review conversion report**: Start with the generated report to identify flagged areas |
| 233 | +- **Use file comparison**: Use built-in diff tools to understand changes |
| 234 | +- **Unit testing**: Execute unit tests against converted code |
| 235 | +- **Integration testing**: Test with actual PostgreSQL database |
| 236 | +- **Performance testing**: Validate query performance meets requirements |
| 237 | + |
| 238 | +## Common mistakes to avoid |
| 239 | + |
| 240 | +### Setup issues |
| 241 | + |
| 242 | +- **Using lower AI models**: Claude Sonnet 4.6 or Claude Opus 4.6 is required for better conversion quality |
| 243 | +- **Skipping schema conversion**: Loses accuracy context and type mapping information |
| 244 | +- **Interrupting agent mid-process**: Causes incomplete conversion and missing files |
| 245 | +- **Wrong database selection**: Pointing to empty database instead of deployed schema |
| 246 | +- **Not reviewing Oracle feature compatibility**: Check [Oracle to Azure Database for PostgreSQL application conversion limitations (Preview)](app-conversions-limitations.md) before starting if you use Oracle Advanced Queuing, Spatial, Text Search, or other specialized features that require architecture planning |
| 247 | + |
| 248 | +### Validation issues |
| 249 | + |
| 250 | +Catch these to prevent production problems. |
| 251 | +- **Assuming all conversions are correct**: AI can miss semantic differences |
| 252 | +- **Skipping integration testing**: Unit tests alone don't catch PostgreSQL-specific issues |
| 253 | +- **Not validating date/time handling**: Oracle vs PostgreSQL date behavior differs significantly |
| 254 | +- **Ignoring performance testing**: Query performance patterns might change |
| 255 | + |
| 256 | +### Process issues |
| 257 | + |
| 258 | +- **Converting without backups**: Always maintain original code separately |
| 259 | +- **Large batch conversions**: Convert in smaller, manageable modules |
| 260 | +- **Skipping team validation**: Have both Oracle and PostgreSQL experts review results |
| 261 | + |
| 262 | +## Language-specific best practices |
| 263 | + |
| 264 | +### Java applications |
| 265 | + |
| 266 | +Focus on JDBC and framework configurations. |
| 267 | + |
| 268 | +**Critical areas to validate**: |
| 269 | +- Review JDBC connection code for PostgreSQL driver usage |
| 270 | +- Validate Hibernate/JPA configuration updates (dialect changes) |
| 271 | +- Check Spring Data repository configurations |
| 272 | +- Test stored procedure annotations and parameter handling |
| 273 | + |
| 274 | +**Common issues**: Connection pool configuration, transaction isolation levels, Oracle-specific annotations |
| 275 | + |
| 276 | +### Python applications |
| 277 | + |
| 278 | +Focus on driver conversion and ORM dialects. |
| 279 | + |
| 280 | +**Critical areas to validate**: |
| 281 | +- Review cx_Oracle to psycopg2/asyncpg conversions |
| 282 | +- Validate SQLAlchemy dialect configurations |
| 283 | +- Check connection pool settings (different libraries) |
| 284 | +- Test parameterized query syntax and type handling |
| 285 | + |
| 286 | +**Common issues**: LOB handling differences, array binding syntax, async patterns |
| 287 | + |
| 288 | +### .NET applications |
| 289 | + |
| 290 | +Focus on provider changes and data access. |
| 291 | + |
| 292 | +**Critical areas to validate**: |
| 293 | +- Review Oracle.DataAccess to Npgsql conversions |
| 294 | +- Validate Entity Framework configuration (provider changes) |
| 295 | +- Check stored procedure call syntax and return handling |
| 296 | +- Test transaction handling code and isolation levels |
| 297 | + |
| 298 | +**Common issues**: REF CURSOR handling, Oracle-specific transaction modes, data type mappings |
| 299 | + |
| 300 | +### Node.js applications |
| 301 | + |
| 302 | +Focus on async patterns and connection management. |
| 303 | + |
| 304 | +**Critical areas to validate**: |
| 305 | +- Review oracledb to pg package conversions |
| 306 | +- Validate connection pool configurations (different APIs) |
| 307 | +- Check async/await patterns with PostgreSQL drivers |
| 308 | +- Test query builder syntax if applicable (Sequelize, Knex) |
| 309 | + |
| 310 | +**Common issues**: Object binding patterns, streaming differences, connection pool behavior |
| 311 | + |
| 312 | +## Post-conversion best practices |
| 313 | + |
| 314 | +<a id="testing-strategy"></a> |
| 315 | + |
| 316 | +### Test strategy |
| 317 | + |
| 318 | +Implement a comprehensive testing strategy: |
| 319 | + |
| 320 | +- **Unit tests**: Run all existing unit tests against converted code |
| 321 | +- **Integration tests**: Test database interactions with PostgreSQL |
| 322 | +- **Regression tests**: Verify existing functionality is preserved |
| 323 | +- **Performance tests**: Validate query and application performance |
| 324 | +- **User acceptance testing**: Conduct UAT in a staging environment |
| 325 | + |
| 326 | +### Code review process |
| 327 | + |
| 328 | +Conduct thorough code reviews: |
| 329 | + |
| 330 | +- Review all flagged files from the conversion report |
| 331 | +- Have Oracle and PostgreSQL experts review critical sections |
| 332 | +- Document any manual changes made post-conversion |
| 333 | +- Update team documentation with conversion patterns |
| 334 | + |
| 335 | +### Documentation updates |
| 336 | + |
| 337 | +Update project documentation to reflect: |
| 338 | + |
| 339 | +- New database connection requirements |
| 340 | +- Changed configuration settings |
| 341 | +- Modified deployment procedures |
| 342 | +- PostgreSQL-specific operational considerations |
| 343 | + |
| 344 | +## Related content |
| 345 | + |
| 346 | +- [What is Oracle to Azure Database for PostgreSQL application conversion (Preview)?](app-conversions-overview.md) |
| 347 | +- [Tutorial: Oracle to Azure Database for PostgreSQL application conversion (Preview)](app-conversions-tutorial.md) |
| 348 | +- [Oracle to Azure Database for PostgreSQL application conversion generated reports (Preview)](app-conversions-reports.md) |
| 349 | +- [Oracle to Azure Database for PostgreSQL application conversion limitations (Preview)](app-conversions-limitations.md) |
0 commit comments