AlphaDB is a powerful and flexible tool for managing MySQL database versions. It allows you to define the structure of your database in a JSON format and simplifies the process of applying and managing migrations across multiple databases. With AlphaDB, you can ensure consistency and control in your database schema evolution, whether you’re working in development, staging, or production environments.
AlphaDB is currently in beta
stage. Breaking changes should be expected.
- JSON-Based Database Schema: Define your database structure in a clear, human-readable JSON format.
- Easy Migration Management: Apply, track, and roll back migrations seamlessly across multiple databases.
- Version Control for Your Database: Keep your database schema in sync with your application code.
- Lightweight and Developer-Friendly: Designed to integrate smoothly into your development workflow.
Visit the official documentation
cargo install alphadb-cli
Connect to a database
alphadb connect
You will be asked to provide the database credentials. After connecting the connection will be saved for later use.
Make sure the database is empty, back it up if necessary. If the database is not empty, you can use the vacate
method.
Note that this function will erase ALL data in the database and this action is irriversible.
alphadb vacate
The database is now ready to be initialized. The init
command will create the adb_conf
table. This holds configuration data for the database.
alphadb init
Now we update the database. For this we need to give it a structure. Read more about version sources.
{
"name": "mydb",
"version": [
{
"_id": "0.1.0",
"createtable": {
"customers": {
"primary_key": "id",
"name": {
"type": "VARCHAR",
"length": 100
},
"id": {
"type": "INT",
"a_i": true
}
}
}
},
{
"_id": "1.0.0",
"createtable": {
"orders": {
"primary_key": "id",
"id": {
"type": "INT",
"a_i": true
},
"date": {
"type": "DATETIME"
},
"note": {
"type": "TEXT",
"null": true
}
}
}
}
]
}
Then run the update command.
alphadb update
You will be asked to select a version source. This can be a path to a JSON file or a URL returning JSON data.