Convert SQL Server code and schema with Gemini assistance
Stay organized with collections
Save and categorize content based on your preferences.
Database Migration Service integrates Gemini for Google Cloud into the
conversion workspaces
to help you speed up and improve the conversion process in the following areas:
Enhance the deterministic conversion results with
Gemini-powered auto-conversion
to use the power of AI to significantly reduce the number of manual adjustments
needed in your PostgreSQL code.
This feature is supported only for upgraded conversion workspaces.
Only freshly created workspaces can be upgraded. For more information,
see
Upgrade a conversion workspace.
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.
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.
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-powered features in Database Migration Service,
do the following:
After you enable Gemini for Google Cloud in
your project,
Conversion assistant and
pattern matching
are automatically enabled for all the conversion workspaces in your project.
To use
auto-conversion, you need to enable it on a per-workspace
basis.
Enabling or disabling each Gemini-powered feature also
depends on whether you use an
upgraded conversion workspace. For more information on
enabling or disabling each feature, see next sections on this page.
Required roles
To get the permissions that you need to use Gemini-enhanced
conversion features, ask your administrator to grant you the
Database Migration Admin (roles/datamigration.admin)
role on your project.
For more information about granting roles, see
Manage access in the Identity and Access Management documentation.
This predefined role contains the permissions required to use
Gemini-enhanced conversion features. To see the exact
permissions that are required, expand the
Required permissions section:
Required permissions
The following permissions are required to perform heterogeneous SQL Server
migrations with Database Migration Service:
datamigration.*
cloudaicompanion.entitlements.get
Use Gemini auto-conversion
When you convert your source schema, Database Migration Service uses the deterministic
conversion rules to create the PostgreSQL syntax equivalents.
Auto-conversion integrates Gemini-powered corrections
on top of the deterministic results to reduce the number of conversion issues
and improve conversion quality.
Convert your source code and schema. Click
move_downConvert source.
Database Migration Service automatically employs Gemini-powered
enhancements in the conversion. You can use the tree view to see which
objects are augmented with Gemini:
Figure 1. Source schema tree view with
Gemini augmentation status. (click to enlarge)
In the tree view, select any augmented object to view the details of
enhancements provided by auto-conversion. If you don't like the changes
introduced by Gemini, click Use deterministic code
instead to revert the object to the deterministic conversion results.
Clear the Auto-conversion checkbox, and click Save settings.
Your conversion workspace will now use deterministic code and schema
conversion when you convert your schema.
Optional: In the Convert source objects? dialog, click
Convert.
Your converted objects aren't modified when you disable auto-conversion.
You can convert your schema again at a later time if you want to
revert the conversion results to use deterministic conversion rules.
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.
Figure 1. Gemini conversion assistant prompts. (click to enlarge)
Enable conversion assistant
Conversion assistant is enabled by default when you enable the
Gemini for Google Cloud in your project.
If you previously disabled the conversion assistant, you can enable
it again in your workspace. The steps to enable the conversion assistant are
different depending on whether you use an upgraded conversion workspace or not.
The rule-based code and schema conversion engine might sometimes encounter
issues when translating objects from SQL Server to PostgreSQL.
For example, certain SQL Server 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 SQL Server panel, select one of your SQL Server 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.
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 SQL Server panel, select one of your SQL Server 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 SQL Server panel, select one of your SQL Server 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 SQL Server panel, select one of your SQL Server 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.
Enable Gemini conversion suggestions
Conversion suggestions are enabled by default when you enable the
Gemini for Google Cloud in your project.
If you previously disabled this feature, you can enable
it again in your workspace. The steps to enable the conversion suggestions are
different depending on whether you use an upgraded conversion workspace or not.
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.
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.
Figure 2. Gemini fix issues dialog.
(click to enlarge)
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025年12月09日 UTC."],[],[]]