A VS Code extension that provides an additional layer of caution when editing SQL migration files marked with a '#locked' comment. It alerts users when editing attempts are made on these locked files and prevents accidental renaming, aiding developers in maintaining the integrity of critical migrati
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
The SQL Migration Locker is a Visual Studio Code extension designed to help
developers manage SQL migration files with greater caution. This extension
identifies SQL files that are marked as locked by inspecting the first line for
a #locked comment. Once detected, the extension monitors edits to these files
and alerts users before allowing any modifications. Additionally, the extension
prevents accidental renaming of these critical files, thereby helping maintain
the integrity of your SQL migration scripts.
Features
Edit Warnings: When you attempt to edit a locked SQL file, a dialog box
will appear asking for confirmation: "You are trying to edit the locked file
. Do you want to proceed?" This helps prevent accidental changes.
Throttle Confirmation Requests: If you opt to edit the file by selecting
"Yes," the system will not prompt the warning dialog again for 5 minutes for
that particular file. If you select "No," the dialog will reappear the next
time you try to edit the file.
Prevent Accidental Renaming: The extension warns and prevents users from
renaming locked SQL files to maintain their original file paths. Should you
attempt to rename a locked migration file, the rename operation will either be
canceled or reverted.
File Decorations: Displays a lock icon (🔒) next to the filename in the
Explorer to signify that the file is locked.
How It Works
File Opening: When a SQL file is opened, the extension checks the first
line for a #locked comment. If found, the file is marked as locked.
Edit Monitoring: The extension listens for edit events on the document.
If it detects changes to a locked file, a confirmation dialog is displayed
unless you've recently opted to proceed with modifications.
Rename Monitoring: Before performing file rename operations, the
extension checks if any targeted files are marked as locked and prevents the
operation if they are.
Throttle Logic: For files where edit changes have been approved, no
confirmation prompts will be triggered for a duration of 5 minutes.
Installation
Open the Extensions view in Visual Studio Code by clicking the Extensions
icon in the Activity Bar or pressing Ctrl+Shift+X.
Search for "SQL Migration Locker".
Click "Install" to add the extension to your VS Code.
Usage
Editing Locked Files: When editing a locked SQL migration file, a modal
dialog will appear seeking confirmation. This dialog ensures that you truly
intend to make changes, helping to prevent accidental modifications.
Renaming Locked Files: Attempts to rename locked files will initiate a
warning dialog. The rename operation will be blocked unless you explicitly
decide to proceed and can trigger a revert if attempted erroneously.
Contributing
We welcome contributions to enhance this extension functionality! If you find
any issues or have ideas for improvements, feel free to submit a pull request or
open an issue in the repository.
License
This extension is licensed under the MIT License. See the LICENSE file for
more information.
The SQL Migration Locker extension serves as a safeguard tool for developers
managing SQL migrations. Keeping your migration scripts locked and secure has
never been easier!