Version Source Verification
AlphaDB includes a powerful verification system that scans your version source for errors and potential issues before you apply any changes to your database. This helps prevent common mistakes, ensures your schema is valid, and can save you from unintended data loss.
Verification is run automatically when you use the update
command, but you can also run it manually through the CLI, Rust, Python, or Node.js APIs.
Issue Priorities
When the verifier finds an issue, it assigns one of three priority levels:
- LOW: The operation will likely succeed, but it might not have any effect, or there might be a better way to do it. For example, a
createtable
block that doesn't define any tables. - HIGH: The operation will still work, but it might produce a different result than you intended. For example, using an unknown method name like
createtablee
instead ofcreatetable
. - CRITICAL: The operation will fail and will not be executed. This could be due to a syntax error, a logical impossibility (like a primary key that doesn't exist), or something that could cause data loss.
What is Verified?
The verifier checks for a wide range of issues, including:
1. Root-Level Structure
- Missing
name
: Every version source must have aname
at the root level. - Missing
version
array: Theversion
array must exist, even if it's empty.
2. Version-Level Structure
- Missing
_id
: Every version object inside theversion
array must have an_id
. - Invalid
_id
: The_id
must be a valid version number string (e.g.,"1.0.0"
). - Unknown methods: The verifier will flag any methods that don't exist (e.g.,
altertablee
).
3. Table and Column Logic
- Primary key validity: In a
createtable
block, the specifiedprimary_key
must match the name of a column defined in the same table. - Dropping a primary key: The verifier will warn you if you try to drop a column that is currently the primary key of a table.
4. Column Attribute Compatibility
Certain column attributes cannot be used together. The verifier will flag these critical errors:
- A column cannot be both
AUTO_INCREMENT
(a_i
) andNULL
. - A column cannot be both
AUTO_INCREMENT
(a_i
) andUNIQUE
. - Other attributes, like
default
, may be incompatible withAUTO_INCREMENT
.
By catching these issues early, AlphaDB helps you write clean, reliable, and safe database schemas.