Convert Oracle code and schema with Gemini assistance

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.

Before you begin

To use Gemini assistance in Database Migration Service conversion workspaces, you need to enable Gemini in Databases for your project. See set up Gemini in Databases for more information.

After you enable Gemini in Databases for 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.

A screenshot that shows how to access Gemini prompts
      for code and schema conversion explainability.
Figure 1. Gemini conversion assistant prompts. (click to enlarge)
A screenshot that shows how to access Gemini prompts
      for code and schema conversion explainability.

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:

  1. In the Google Cloud console, go to Conversion workspaces.

    Go to Conversion workspaces

  2. From the list of available conversion workspaces, select the conversion workspace that you want to work with.

    The conversion workspace editor opens.

  3. In the Oracle panel, select one of your Oracle objects.

  4. In the object details view, select Conversion assistant > Help me fix object conversion issues.

    A pane with prompt results opens.

  5. 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.

  6. 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:

  1. In the Google Cloud console, go to Conversion workspaces.

    Go to Conversion workspaces

  2. From the list of available conversion workspaces, select the conversion workspace that you want to work with.

    The conversion workspace editor opens.

  3. In the Oracle panel, select one of your Oracle objects.

  4. 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:

  1. In the Google Cloud console, go to Conversion workspaces.

    Go to Conversion workspaces

  2. From the list of available conversion workspaces, select the conversion workspace that you want to work with.

    The conversion workspace editor opens.

  3. In the Oracle panel, select one of your Oracle objects.

  4. In the object details view, select Conversion assistant > Help me optimize this code.

    A pane with prompt results opens.

  5. 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:

  1. In the Google Cloud console, go to Conversion workspaces.

    Go to Conversion workspaces

  2. From the list of available conversion workspaces, select the conversion workspace that you want to work with.

    The conversion workspace editor opens.

  3. In the Oracle panel, select one of your Oracle objects.

  4. In the object details view, select Conversion assistant > Add comments to explain the purpose of this object.

    A pane with prompt results opens.

  5. 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 suggestions:

  1. In the Google Cloud console, go to Conversion workspaces.

    Go to Conversion workspaces

  2. From the list of available conversion workspaces, select the conversion workspace that you want to work with.

    The conversion workspace editor opens.

  3. In the Oracle panel, select the object whose generated SQL you want to adjust.

  4. 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.

    Gemini fix issues dialog.
    Figure 2. Gemini fix issues dialog. (click to enlarge)
    Gemini fix issues dialog.
  5. 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:

  1. Click an object to display the related AI-suggested fix.
  2. Review and edit the code that Gemini models suggested.
  3. 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:

  1. On the Fix issues with Gemini page, click the back arrow.
  2. 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:

  1. In the Google Cloud console, go to Conversion workspaces.

    Go to Conversion workspaces

  2. From the list of available conversion workspaces, select the conversion workspace that you want to work with.

    The conversion workspace editor opens.

  3. 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