Database Migration Service integrates Gemini for Google Cloud into the conversion workspaces to help you speed up and improve the conversion process in two areas:
Provide code explainability features with the conversion assistant: a set of dedicated prompts that can help you better understand the conversion logic, propose fixes for conversion issues, or optimize converted code.
Expedite applying fixes for conversion issues with Gemini code conversion suggestions: a mechanism where the Gemini model can learn as you fix conversion issues and suggest changes to other faulty objects in the workspace.
You can also combine the two approaches for a complete end-to-end Gemini-assisted code object conversion experience. For more information, see Example workflow for fixing code objects with conversion issues.
Your SQL code and schema are stored in the region where you create the conversion workspace. If you use assisted code and schema conversion with Gemini models, your code and schemas might be processed in other regions.
Learn how and when Gemini for Google Cloud uses your data.
Costs
To use Gemini assistance in Database Migration Service conversion workspaces you need to enable Gemini for Google Cloud API. Pricing for Gemini applies. For more information, see Gemini for Google Cloud pricing.
Before you begin
To use Gemini assistance in Database Migration Service conversion workspaces, you need to enable Gemini for Google Cloud in your project.
After you enable Gemini for Google Cloud in your project, Gemini features are enabled for all your conversion workspaces. You can later disable the suggestions in a specific workspace.
Use Gemini conversion assistant
The conversion assistant is a set of dedicated prompts that you can use to gain a better understanding of the object conversion logic, ask for ideas on how to optimize code and remedy your conversion issues, or even add comments to your schema for self-documenting database objects.
Help me fix object conversion issues
The rule-based code and schema conversion engine might sometimes encounter issues when translating objects from Oracle to PostgreSQL. For example, certain Oracle functions might not have direct equivalents in PostgreSQL. You can use the Help me fix object conversion issues prompt to get a proposal of code changes that can fix the conversion issue.
This prompt is only available for editable code objects that have conversion issues. You can't view this prompt for other types of objects in the conversion workspace.
To use this prompt, do the following:
In the Google Cloud console, go to Conversion workspaces.
From the list of available conversion workspaces, select the conversion workspace that you want to work with.
The conversion workspace editor opens.
In the Oracle panel, select one of your Oracle objects.
In the object details view, select Conversion assistant > Help me fix object conversion issues.
A pane with prompt results opens.
Verify the diff screen that shows proposed improvements. If you like the results, you can use the Insert suggestion button to update the converted object.
Repeat the steps for every faulty code object. As you apply the code proposals, Gemini models learn the pattern and can offer suggestions on how to propagate the fixes to all faulty objects in your workspace.
Explain the conversion logic for this object
With the Explain the conversion logic for this object prompt, you can get a step-by-step explanation of what the converted code does, including a summary of best practices applied in the new code.
To request an explanation of the object conversion logic, do the following:
In the Google Cloud console, go to Conversion workspaces.
From the list of available conversion workspaces, select the conversion workspace that you want to work with.
The conversion workspace editor opens.
In the Oracle panel, select one of your Oracle objects.
In the object details view, select Conversion assistant > Explain the conversion logic for this object.
A pane with prompt results opens.
Help me optimize this code
Sometimes the results of rule-based code and schema conversion can be technically correct, but not fully optimized for PostgreSQL environments. You can use the Help me optimize this code prompt to get a proposal with code optimizations for your database object.
To use this prompt, do the following:
In the Google Cloud console, go to Conversion workspaces.
From the list of available conversion workspaces, select the conversion workspace that you want to work with.
The conversion workspace editor opens.
In the Oracle panel, select one of your Oracle objects.
In the object details view, select Conversion assistant > Help me optimize this code.
A pane with prompt results opens.
In the results panel, read the explanation, review the code, and make sure proposal is in line with what you need. If you like the results, you can use the Insert suggestion button to update the converted object.
Add comments to explain the purpose of this object
The Add comments to explain the purpose of this object prompt produces a proposal for code comments that you can add to your database object for self-documenting schema.
To use this prompt, do the following:
In the Google Cloud console, go to Conversion workspaces.
From the list of available conversion workspaces, select the conversion workspace that you want to work with.
The conversion workspace editor opens.
In the Oracle panel, select one of your Oracle objects.
In the object details view, select Conversion assistant > Add comments to explain the purpose of this object.
A pane with prompt results opens.
In the results panel, read the explanation, review the code, and make sure proposal is in line with what you need. If you like the results, you can use the Insert suggestion button to update the converted object.
Propagate conversion issue fixes with Gemini code conversion
When you fix conversion issues in your workspace, Gemini models can learn from your fixes and suggest changes to other faulty objects in the workspace. This way you can propagate your fixes to multiple objects without making all edits manually.
View Gemini conversion suggestions in Database Migration Service
When you fix object issues (by editing the SQL object's code or applying the code proposed by the Help me fix object conversion issues prompt), Gemini models analyze your changes. After enough changes are made, Gemini integration displays a prompt and suggests further edits.
To access Gemini-assisted suggestions:
In the Google Cloud console, go to Conversion workspaces.
From the list of available conversion workspaces, select the conversion workspace that you want to work with.
The conversion workspace editor opens.
In the Oracle panel, select the object whose generated SQL you want to adjust.
Fix conversion issues that you encounter with the object and save code changes. You can edit the code manually, or use the Help me fix object conversion issues prompt.
Gemini models analyze your most recent fixes until it can suggest similar updates to other objects with conversion issues. When Gemini models have analyzed enough of your fixes, the Review suggestions from Gemini dialog is displayed.
To view AI-generated suggestions that are based on the changes you made, click Review suggestions.
Review Gemini conversion suggestions
The Fix issues with Gemini page displays suggestions generated by Gemini models based on the code changes that you have made. These suggestions contain similar changes that you can apply to other objects. For every suggestion, you can review, change, accept, or ignore the suggestion.
The Fix issues with Gemini page displays three variants of an object's source code, which you can select in the Edit view menu:
- Original source code (read-only)
- Draft destination source code (read-only)
- Destination source code generated with Gemini assistance (editable)
The Objects pane contains a list of objects that have issues and fixes suggested by Gemini models.
To review Gemini suggestions, follow these steps:
- Click an object to display the related AI-suggested fix.
- Review and edit the code that Gemini models suggested.
Do one of the following:
To accept the suggestion (including your edits), click Accept code. The changes are applied to the object in the conversion workspace, and the object state in the objects list changes from Pending to Accepted.
To keep the suggestion (including your edits) without applying the changes, switch to a different object. The object remains in the Pending state. You can edit the code and accept or ignore the suggestion later.
To ignore pending or accepted suggestions (and revert your edits), click Ignore code. The object state in the objects list changes from Pending to Ignored. Your changes are reverted. You can edit the code and apply it later.
To close Gemini suggestions and discard all changes that you haven't applied, follow these steps:
- On the Fix issues with Gemini page, click the back arrow.
In the Close Gemini dialog, click Close.
The current Gemini session is closed. To go back to the suggestions page, access Gemini suggestions again.
Disable Gemini conversion suggestions
By default, Gemini conversion suggestions are enabled for your conversion workspaces after you enable Gemini for your project. You can disable Gemini suggestions in a specific conversion workspace. To disable Gemini code fix suggestions, perform the following steps:
In the Google Cloud console, go to Conversion workspaces.
From the list of available conversion workspaces, select the conversion workspace that you want to work with.
The conversion workspace editor opens.
In the taskbar, click pen_spark Gemini and select Code suggestion.
Gemini code conversion suggestions are now disabled for this conversion workspace.
What's next
- See how to work with conversion workspaces.
- Read Gemini for Google Cloud overview.
- Learn how Gemini uses your data.
- Follow the sample workflow for fixing conversion issues with Gemini assistance.