{"slug": "accelerate-postgresql-migrations-using-gemini-in-database-migration-service", "title": "Accelerate PostgreSQL migrations using Gemini in Database Migration Service", "summary": "Google Cloud's Database Migration Service now includes Gemini-powered AI code conversion to translate stored procedures, triggers, and functions from Oracle PL/SQL and SQL Server T-SQL into PostgreSQL PL/pgSQL, addressing the most complex part of database migrations. The service provides full schema context, enterprise security, an integrated workspace, and deterministic accuracy by combining compiler rules with Gemini's contextual synthesis.", "body_md": "Imagine this scenario: Your team decides to migrate a core application from an existing commercial database like Oracle or SQL Server to open source PostgreSQL or a fully managed service such as [AlloyDB for PostgreSQL](https://cloud.google.com/products/alloydb).\n\nThe initial phase goes smoothly. Schemas convert, tables populate, and data migration pipelines transfer terabytes of data in hours. The project looks ahead of schedule.\n\nThen your team hits the bottleneck.\n\nBuried inside the existing databases are hundreds of stored procedures, complex triggers, and custom functions written in proprietary SQL dialects like PL/SQL or T-SQL. These routines contain years of critical business logic handling transaction validation, order processing, and custom reporting.\n\nSuddenly, your modernization project halts. Translating thousands of lines of procedural logic demands specialized dual-dialect expertise, months of manual rewriting, and high risk of conversion errors. This code translation represents the \"last mile\" bottleneck of database migration and is the most complex part of migrations.\n\nThankfully, recent advancements in AI provide a solution to the last mile problem. [Database Migration Service](https://cloud.google.com/database-migration) (DMS) includes AI-assisted code conversion powered by Gemini. By bringing generative AI directly into your migration workflow, you can convert stored procedures, triggers, and custom functions into PostgreSQL PL/pgSQL code faster and with higher accuracy.\n\nCommercial database engines rely on vendor-specific syntax for stored procedures, user-defined functions, package bodies, and conditional logic. Converting this logic to PostgreSQL PL/pgSQL requires mapping variable definitions, exception handling blocks, cursor loops, and built-in functions.\n\nWhen migrating complex enterprise schemas with hundreds of stored procedures, manual code conversion often demands months of engineering effort. Database teams must parse legacy logic line by line, re-implement conditional branches, and verify data type conversions between engines.\n\nGemini in Database Migration Service accelerates this conversion work directly inside the Google Cloud console. DMS provides automated schema conversion alongside AI-generated code suggestions that explain structural differences between the source dialect and PostgreSQL.\n\nThe service presents converted PL/pgSQL code side-by-side with original source code, allowing database teams to review, edit, and validate suggestions in real time.\n\nMost AI apps and tools from major vendors have the ability to generate and convert code, including SQL code. However, converting enterprise databases demands far more than snippet translation offered by generic AI chat tools. Gemini in Database Migration Service offers several key advantages:\n\n**Full schema context:** Rather than evaluating code snippets in isolation, Gemini in DMS analyzes your entire database context, including table relationships, data types, dependent views, and cross-procedure references across the whole migration project.\n\n**Enterprise security and privacy:** Code conversion runs strictly within your Google Cloud project boundaries and IAM governance, protecting proprietary business logic and intellectual property.\n\n**Integrated execution workspace:** DMS eliminates manual copy-pasting across hundreds of files. You can review side-by-side diffs, inspect inline AI explanations, edit code, and deploy validated PL/pgSQL routines directly to target databases within a single console.\n\n**Deterministic accuracy and AI compilation**: DMS pairs deterministic compiler rules for 1:1 mappings (such as standard DDL transformations, scalar functions, and well-defined syntax conversions) with Gemini contextual synthesis for complex procedural blocks—guaranteeing exact, predictable translation without model drift.\n\nConsider an Oracle PL/SQL stored procedure that calculates customer order totals and applies tier-based discounts using proprietary NVL and DECODE functions. In the original workflow, you must manually map NVL to COALESCE, rewrite DECODE statements as standard CASE expressions, and adjust exception blocks like WHEN NO_DATA_FOUND THEN.\n\nWhen you run a migration assessment in DMS, Gemini analyzes the source procedure and produces native PostgreSQL PL/pgSQL code:\n\n**Source: Oracle PL/SQL**\n\n**Target: PostgreSQL PL/pgSQL (Converted by Gemini in DMS)**\n\nAlong with the generated SQL, Gemini provides an inline explanation detailing why NVL was converted to COALESCE and how the Oracle DECODE function was converted into an explicit CASE block in PostgreSQL.\n\nSecurity, transparency, and code accuracy remain central to database modernization. Gemini in DMS operates strictly within your established Google Cloud security boundaries, keeping your code private to your project.\n\nTo ensure reliability, the conversion and validation process follows a structured workflow:\n\n**Automatic schema context pulling:** When you set up a DMS conversion workspace, the service automatically parses your entire source database metadata—including table schemas, data types, foreign key constraints, and cross-procedure dependencies. Gemini references this project-wide context during code generation, eliminating the need to manually supply dependent object definitions.\n\n**Automated syntax and dependency validation:** As code is generated, DMS runs a validation parser against target PostgreSQL syntax rules. Objects are assigned validation status indicators (e.g. Converted, Warning, or Action Required) to quickly highlight routines requiring manual review.\n\n**Interactive evaluation state:** You maintain full control over every schema change. Within the conversion workspace, you can inspect side-by-side diffs, review inline AI explanations, and edit PL/pgSQL code directly before applying changes to your target database.\n\n**Staging deployment and verification:** Once code passes workspace validation, you can apply the converted schema and functions to a target staging instance (e.g. [Cloud SQL](https://cloud.google.com/sql) or AlloyDB) for functional execution and performance testing prior to production cutover.\n\nAI-assisted code conversion in Database Migration Service helps database teams convert legacy database logic in days rather than months. Instead of spending precious time rewriting code from scratch, database administrators and application developers can shift their focus to adding new functionality, testing performance, and modernizing applications.\n\nIf you’d like some good examples of common Oracle and SQL Server conversion scenarios and how DMS converts them to PostgreSQL, check out our recent video series, [Gemini taught me PostgreSQL](https://www.youtube.com/watch?v=MGNPQZiUl6c).\n\nTo start your database conversion, launch a migration assessment in the Database Migration Service console ([https://console.cloud.google.com/dms](https://console.cloud.google.com/dms)) or read our heterogeneous migration guide ([https://cloud.google.com/database-migration](https://cloud.google.com/database-migration)).", "url": "https://wpnews.pro/news/accelerate-postgresql-migrations-using-gemini-in-database-migration-service", "canonical_source": "https://cloud.google.com/blog/products/databases/accelerate-postgresql-migrations-with-gemini-in-dms/", "published_at": "2026-08-11 16:00:00+00:00", "updated_at": "2026-08-11 16:38:16.500724+00:00", "lang": "en", "topics": ["generative-ai", "ai-tools", "ai-products"], "entities": ["Google Cloud", "Database Migration Service", "Gemini", "PostgreSQL", "AlloyDB for PostgreSQL", "Oracle", "SQL Server"], "alternates": {"html": "https://wpnews.pro/news/accelerate-postgresql-migrations-using-gemini-in-database-migration-service", "markdown": "https://wpnews.pro/news/accelerate-postgresql-migrations-using-gemini-in-database-migration-service.md", "text": "https://wpnews.pro/news/accelerate-postgresql-migrations-using-gemini-in-database-migration-service.txt", "jsonld": "https://wpnews.pro/news/accelerate-postgresql-migrations-using-gemini-in-database-migration-service.jsonld"}}