Prisma Bypass MySQL
Roda migrations, seeders e SQL avulso direto no MySQL quando o banco não permite 🇧🇷 Português (abaixo) | 🇺🇸 English Por que essa extensão existeAlguns provedores de MySQL (hospedagem compartilhada, dbaas etc.) não liberam as permissões que o Prisma exige para rodar Como alternativa, os arquivos de migration/schema/seed continuam sendo gerados normalmente (mantendo a estrutura do Prisma para o dia em que o ambiente mudar), mas precisam ser aplicados manualmente: abrir o Essa extensão elimina o copia-e-cola: com um clique no editor, o conteúdo do arquivo (ou só a parte selecionada) é executado direto no banco configurado no ConfiguraçãoA extensão lê a conexão do arquivo 1.
2. Variáveis separadas (quando não há uma URL única)
Se nenhuma das duas formas for encontrada, a extensão pede a string de conexão manualmente antes de rodar. ComandosCom um arquivo
Ambos também estão disponíveis no clique direito (menu de contexto) e na paleta de comandos ( Ao selecionar um trecho de SQL, também aparece um link "▶ Rodar seleção SQL" flutuando na linha logo acima da seleção (CodeLens), sem precisar ir até a barra do editor. Comandos adicionais via paleta:
Detecção automática (migrations e seeds)A extensão observa o workspace em segundo plano e, quando detecta uma mudança relevante, mostra uma notificação com o botão "Rodar agora" — um clique roda, sem precisar abrir o arquivo ou o comando manualmente:
Isso substitui o clique no ícone de play: você só confirma a notificação. Para evitar disparos em cascata, mudanças próximas no tempo são agrupadas (debounce de ~1s) antes de perguntar. Por padrão a pasta observada é
A extensão passa a observar Se preferir voltar ao fluxo 100% manual, desative em
Rodar sem perguntar (
|
| Icon | Action | When it shows up |
|---|---|---|
| ▶ Run Current SQL File | Executes the whole file | Always, on any .sql |
| ▶ Run SQL Selection | Executes only the selected text | Only when there's a text selection |
Both are also available via right-click (context menu) and the command palette (Ctrl+Shift+P → "Prisma Bypass"). A confirmation modal is always shown before running anything.
When you select a chunk of SQL, a "▶ Run selection" link (CodeLens) also floats on the line right above the selection, so you don't need to reach for the editor toolbar.
Additional commands via the palette:
- Prisma Bypass: Test Connection — runs a
SELECT 1(read-only, no risk) to validate the credentials. - Prisma Bypass: Run Pending Migrations — scans
prisma/migrations/*/migration.sql, applying only the ones not yet recorded in the_prisma_bypass_migrationscontrol table (created automatically in the database), in the folders' chronological order. Each SQL statement in the file runs individually: if one fails, the rest keep going, and a success/failure summary is shown at the end. - Prisma Bypass: Mark Migrations As Applied (without running) — for when the database already has a migration's tables/changes (applied by hand, by another tool, or from before you started using this extension), but it isn't recorded in
_prisma_bypass_migrationsyet. Opens a picker with the pending migrations so you can mark the ones that already exist in the database — they count as applied without running the SQL, and the next deploy only runs what's actually left.
Automatic detection (migrations and seeds)
The extension watches the workspace in the background and, when it detects a relevant change, shows a notification with a "Run now" button — one click runs it, no need to open the file or command manually:
- New migration under
prisma/migrations/*/migration.sql→ offers to run the pending migrations (same flow as the "Run Pending Migrations" command). - Any
.sqlfile changed directly inprisma/(e.g.prisma/seed.sql) → offers to run that specific file against the database.
This replaces clicking the play icon: you just confirm the notification. To avoid firing repeatedly, changes that happen close together in time are grouped (debounced ~1s) before asking.
By default the watched folder is prisma/, but not every project uses that name. If your project keeps migrations/seeds in a different folder (e.g. database/), set it in that project's .vscode/settings.json (not in global/user settings, otherwise it would apply to every workspace you open):
{
"prismaBypass.rootFolder": "database"
}
The extension then watches database/migrations/*/migration.sql and database/*.sql for that specific workspace; other projects keep using the prisma/ default.
To go back to a fully manual flow, disable it in Settings → prismaBypass.autoDetect (or in that project's settings.json):
"prismaBypass.autoDetect": false
Run without asking (autoRun)
If you want detected migrations/seeds to run straight against the database with no click needed, there are two ways to turn that on:
- Click "Always (don't ask again)" on the notification itself — the extension enables the setting for that workspace and runs the current change right away.
- Or set it directly in the project's
.vscode/settings.json:
{
"prismaBypass.autoRun": true
}
With autoRun on, the notification stops showing up: the extension just applies the change and reports success/failure. This removes the manual confirmation step — only enable it where running migrations/seeds automatically without review is acceptable (e.g. a local dev database), not in production.
Terminal usage (without opening VS Code)
All the logic also runs via CLI, useful for automation or a quick manual test:
npm run cli test <projectPath>
npm run cli run <projectPath> <file.sql>
npm run cli deploy <projectPath>
npm run cli status <projectPath>
npm run cli mark-applied <projectPath> <migration1,migration2,...>
run and deploy require a typed confirmation (sim) before opening any connection.
Security
- No execution happens without the user's explicit confirmation.
- The database connection is opened only when running a command and closed right after — it's never kept open in the background.
- The deploy command never reapplies a migration already recorded in the
_prisma_bypass_migrationstable.