Skip to content

Fixing rename databases#21899

Merged
aasimkhan30 merged 13 commits intomainfrom
aasim/fix/renameDatabase
Apr 23, 2026
Merged

Fixing rename databases#21899
aasimkhan30 merged 13 commits intomainfrom
aasim/fix/renameDatabase

Conversation

@aasimkhan30
Copy link
Copy Markdown
Contributor

@aasimkhan30 aasimkhan30 commented Apr 14, 2026

Description

Adds a new webview to rename database. This lets user generate scripts and close exiting connections.
Previously, if there was any existing connections, the rename object was just stuck until they were closed.
image

Depends on microsoft/sqltoolsservice#2652

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Aasim Khan added 3 commits April 14, 2026 10:09
- Introduced a new webview for renaming databases, including a dialog page and form.
- Implemented the RenameDatabaseWebviewController to handle the renaming logic.
- Added constants and localization for the rename database feature.
- Created SVG icons for the rename database action.
- Updated the object management service to support renaming databases.
- Added tests for the new rename database functionality, ensuring correct request handling and error management.
Copilot AI review requested due to automatic review settings April 14, 2026 17:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Rename Database webview workflow so users can rename databases (optionally dropping active connections) and generate scripts, replacing the previous inline input-box flow that could get stuck when connections exist.

Changes:

  • Introduces a new Rename Database object-management webview (UI, controller, bundling, icons, localization).
  • Adds a new SQL Tools contract + service method for rename-database operations and wires it into the main controller command.
  • Adds unit tests for the new controller flow and the service request payload.

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
localization/xliff/vscode-mssql.xlf Adds new localized strings used by the rename-database UI.
extensions/mssql/test/unit/renameDatabaseWebviewController.test.ts New unit tests covering controller initialization, submit, script, and error paths.
extensions/mssql/test/unit/objectManagementService.test.ts Adds a unit test validating the rename-database request contract and parameters.
extensions/mssql/src/webviews/pages/ObjectManagement/renameDatabaseIndex.tsx New webview entrypoint wiring providers and the rename page.
extensions/mssql/src/webviews/pages/ObjectManagement/renameDatabaseForm.tsx New form UI for rename options and database details.
extensions/mssql/src/webviews/pages/ObjectManagement/renameDatabaseDialogPage.tsx New dialog page implementing validation and RPC actions (submit/script/help/cancel).
extensions/mssql/src/webviews/common/locConstants.ts Adds localized strings for the rename database webview.
extensions/mssql/src/webviews/common/icons/renameDatabase.tsx Adds a new icon component for the rename database dialog.
extensions/mssql/src/sharedInterfaces/objectManagement.ts Extends shared object-management interfaces to support rename database dialog/types.
extensions/mssql/src/services/objectManagementService.ts Adds renameDatabase and adjusts initializeView signature.
extensions/mssql/src/models/contracts/objectManagement.ts Introduces RenameDatabaseRequest contract for SQL Tools RPC.
extensions/mssql/src/controllers/renameDatabaseWebviewController.ts New controller managing the rename database webview lifecycle and actions.
extensions/mssql/src/controllers/mainController.ts Replaces old rename flow with new rename webview controller integration.
extensions/mssql/src/constants/locConstants.ts Adds a rename database webview title constant.
extensions/mssql/src/constants/constants.ts Adds a help link for rename database.
extensions/mssql/scripts/bundle-webviews.js Bundles the new rename database webview entrypoint.
extensions/mssql/media/renameDatabase_light.svg Adds light-theme SVG asset for the rename dialog.
extensions/mssql/media/renameDatabase_dark.svg Adds dark-theme SVG asset for the rename dialog.
extensions/mssql/l10n/bundle.l10n.json Adds localized strings for the new rename database webview.

Comment thread extensions/mssql/test/unit/renameDatabaseWebviewController.test.ts Outdated
Comment thread extensions/mssql/src/webviews/common/locConstants.ts Outdated
Comment thread extensions/mssql/src/webviews/common/icons/renameDatabase.tsx Outdated
Comment thread extensions/mssql/src/webviews/common/icons/renameDatabase.tsx
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 78048 KB 78003 KB ⚪ -45 KB ( 0% )
sql-database-projects VSIX 6221 KB 6212 KB ⚪ -9 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )
keymap VSIX 7 KB 7 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 81.95122% with 74 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.70%. Comparing base (8164973) to head (06c4a3d).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...tensions/mssql/src/webviews/common/locConstants.ts 11.42% 31 Missing ⚠️
...src/controllers/renameDatabaseWebviewController.ts 89.36% 20 Missing ⚠️
extensions/mssql/src/controllers/mainController.ts 5.26% 18 Missing ⚠️
...src/controllers/createDatabaseWebviewController.ts 86.84% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21899      +/-   ##
==========================================
+ Coverage   74.65%   74.70%   +0.04%     
==========================================
  Files         392      393       +1     
  Lines      117355   117667     +312     
  Branches     6710     6728      +18     
==========================================
+ Hits        87617    87907     +290     
- Misses      29738    29760      +22     
Flag Coverage Δ
data-workspace 77.10% <ø> (ø)
mssql 74.36% <81.95%> (+0.05%) ⬆️
sqlproj 77.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
extensions/mssql/src/configurations/config.ts 100.00% <100.00%> (ø)
extensions/mssql/src/constants/constants.ts 100.00% <100.00%> (ø)
extensions/mssql/src/constants/locConstants.ts 75.50% <100.00%> (-0.01%) ⬇️
...l/src/controllers/dropDatabaseWebviewController.ts 86.41% <100.00%> (+1.38%) ⬆️
...ons/mssql/src/models/contracts/objectManagement.ts 100.00% <100.00%> (ø)
...ions/mssql/src/services/objectManagementService.ts 100.00% <100.00%> (ø)
...ons/mssql/src/sharedInterfaces/objectManagement.ts 100.00% <100.00%> (ø)
...src/controllers/createDatabaseWebviewController.ts 83.66% <86.84%> (+1.03%) ⬆️
extensions/mssql/src/controllers/mainController.ts 36.00% <5.26%> (+0.25%) ⬆️
...src/controllers/renameDatabaseWebviewController.ts 89.36% <89.36%> (ø)
... and 1 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

kburtram
kburtram previously approved these changes Apr 14, 2026
lewis-sanchez
lewis-sanchez previously approved these changes Apr 14, 2026
Copilot AI review requested due to automatic review settings April 22, 2026 19:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 21 changed files in this pull request and generated 2 comments.

Comment thread extensions/mssql/test/unit/objectManagementService.test.ts Outdated
Comment thread extensions/mssql/src/constants/locConstants.ts Outdated
Aasim Khan and others added 2 commits April 22, 2026 13:07
…riable naming and improve error handling in save and drop operations

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings April 23, 2026 01:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (3)

extensions/mssql/test/unit/objectManagementService.test.ts:91

  • These tests assert calledOnce / use firstCall.args, which makes them brittle if additional requests are added later. Prefer asserting the expected request payload with calledWith / calledWithMatch and avoid call-count / call-index assertions.
        expect(sqlToolsClientStub.sendRequest.calledOnce).to.be.true;
        const [type, params] = sqlToolsClientStub.sendRequest.firstCall.args;
        expect(type).to.equal(SaveObjectRequest.type);
        expect(params).to.deep.equal({

extensions/mssql/test/unit/dropDatabaseWebviewController.test.ts:129

  • This test relies on exact call count/order (calledOnce, firstCall.args), which is brittle if the controller starts making additional calls. Prefer asserting the expected params with calledWithMatch rather than using call-count/index assertions.
        expect(objectManagementServiceStub.dropDatabase.calledOnce).to.be.true;
        const args = objectManagementServiceStub.dropDatabase.firstCall.args;
        expect(args[1]).to.equal(databaseName);
        expect(args[2]).to.be.true; // dropConnections

extensions/mssql/src/controllers/dropDatabaseWebviewController.ts:167

  • handleScript doesn't check response.errorMessage before falling back to the generic "No script generated" warning when script is missing. If the service returns a specific failure reason, return/surface that message so the dialog shows the real error.
            const script = response.script;

            if (!script) {
                void this.vscodeWrapper.showWarningMessage(LocConstants.msgNoScriptGenerated);
                return {

Comment thread extensions/mssql/src/controllers/renameDatabaseWebviewController.ts Outdated
Comment thread extensions/mssql/test/unit/createDatabaseWebviewController.test.ts
Comment thread extensions/mssql/src/webviews/common/locConstants.ts
Copilot AI review requested due to automatic review settings April 23, 2026 17:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (2)

extensions/mssql/src/controllers/dropDatabaseWebviewController.ts:169

  • handleScript ignores response.errorMessage when no script is returned and always shows msgNoScriptGenerated. Since the response type now includes an errorMessage, prefer surfacing that message (falling back to msgNoScriptGenerated) so users get the real failure reason.
            if (!script) {
                void this.vscodeWrapper.showWarningMessage(LocConstants.msgNoScriptGenerated);
                return {
                    success: false,
                    errorMessage: LocConstants.msgNoScriptGenerated,

extensions/mssql/test/unit/dropDatabaseWebviewController.test.ts:130

  • This test uses calledOnce plus firstCall.args (call index) to validate behavior, which is brittle per the repo’s test guidelines. Prefer calledWith/calledWithMatch against the expected arguments, and avoid the setTimeout-based waitForInitialization (use a promise that resolves when initializeView completes, as done in the renameDatabase controller tests).
        expect(objectManagementServiceStub.dropDatabase.calledOnce).to.be.true;
        const args = objectManagementServiceStub.dropDatabase.firstCall.args;
        expect(args[1]).to.equal(databaseName);
        expect(args[2]).to.be.true; // dropConnections
        expect(args[3]).to.be.false; // deleteBackupHistory

Comment thread extensions/mssql/src/controllers/createDatabaseWebviewController.ts
Comment thread extensions/mssql/src/controllers/renameDatabaseWebviewController.ts
Comment thread extensions/mssql/test/unit/createDatabaseWebviewController.test.ts
Comment thread extensions/mssql/test/unit/objectManagementService.test.ts
Comment thread extensions/mssql/test/unit/objectManagementService.test.ts
Comment thread extensions/mssql/src/controllers/dropDatabaseWebviewController.ts
@aasimkhan30 aasimkhan30 merged commit 5ee5c09 into main Apr 23, 2026
7 checks passed
@aasimkhan30 aasimkhan30 deleted the aasim/fix/renameDatabase branch April 23, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants