Menu

1 / 2

Automated SQL Migration Review with Real CLI Output (MySQL, PostgreSQL, TiDB)

DEV Community·Fan()·6 months ago
#FCysP3pV
#scenario#cli#database#showdev#table
Reading 0:00
15s threshold

Auditing MySQL ALTER TABLE Risks with a CLI (Real Output Included)

Background

I'm the author of DeltaScope , an open-source offline SQL audit tool that supports MySQL, TiDB, and PostgreSQL. This post skips the marketing and shows real SQL inputs with real audit outputs — no fabrications.

Scenario 1: An Innocent-Looking Migration File

Consider a migration file migration.sql :

-- Add columns and index to users table ALTER TABLE users ADD COLUMN phone VARCHAR ( 20 ); ALTER TABLE users ADD COLUMN age INT DEFAULT 0 ; ALTER TABLE users ADD INDEX idx_phone ( phone );

-- Clean up temp data DELETE FROM temp_data ;

Enter fullscreen mode

Exit fullscreen mode

Audit it:

deltascope audit --file migration.sql

Enter fullscreen mode

Exit fullscreen mode

Output:

Verdict: reject

- Statements: 4 - Blockers: 1 - Warnings: 1 - Notices: 0

## Statement 1 - SQL: ALTER TABLE users ADD COLUMN phone VARCHAR(20) No findings.

## Statement 2 - SQL: ALTER TABLE users ADD COLUMN age INT DEFAULT 0 No findings.

## Statement…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.