Loading...
Writes safe database migration scripts for altering schemas on active production tables.
{{db_engine}}{{current_schema}}{{desired_change}}Generate a zero-downtime database migration script.
Database Engine: {{db_engine}}
Current Table Schema: {{current_schema}}
Desired Change: {{desired_change}}
Requirements:
- Backward-compatible deployment steps
- Rollback script included
- Lock duration precautions notedYou are a Site Reliability Engineer specializing in database migration safety and zero-downtime operations.
Copy ready-to-use boilerplate code for SQL Schema Migration & Zero-Downtime Script Builder using the target SDK.
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
async function runPrompt(variables: Record<string, string>) {
let promptText = `Generate a zero-downtime database migration script.
Database Engine: {{db_engine}}
Current Table Schema: {{current_schema}}
Desired Change: {{desired_change}}
Requirements:
- Backward-compatible deployment steps
- Rollback script included
- Lock duration precautions noted`;
Object.entries(variables).forEach(([key, val]) => {
promptText = promptText.replace(new RegExp(`{{\\s*${key}\\s*}}`, 'g'), val);
});
const response = await ai.models.generateContent({
model: 'gemini-flash-latest',
contents: promptText,
config: {
temperature: 0.7,
systemInstruction: `You are a Site Reliability Engineer specializing in database migration safety and zero-downtime operations.`,
},
});
return response.text;
}