| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A lightweight, dependency-minimal MySQL schema migration tool written in C++17. Instead of a developer manually logging into MySQL Workbench to create a table, they write a script. The tool automatically detects if that script has been run and executes it. This removes the risk of someone forgetting to update the database.
| Tool | Version |
|---|---|
| C++ compiler | GCC 9+ or Clang 10+ |
| CMake | 3.16+ |
| MySQL client lib | libmysqlclient-dev |
Ubuntu / Debian:
sudo apt update
sudo apt install build-essential cmake libmysqlclient-devpowershell:
vcpkg install mysql-connector-cpp:x64-windowsmacOS:
brew install cmake mysql-clientgit clone https://github.com/Sourcedevkh/migrate.git
cd migrate
mkdir build && cd build
cmake ..
make
# Binary is at: build/migrate# 1. Initialize project (creates config + example migration)
./migrate init
# 2. Edit your database credentials
nano migrate.conf
# 3. Check migration status
./migrate status
# 4. Run pending migrations
./migrate upEdit cpp-migrate.conf:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=secret
DB_NAME=my_app
MIGRATIONS_DIR=./migrationsName your files with a numeric prefix:
migrations/ 001_create_users.sql 002_add_email_column.sql 003_create_posts.sql
Each file can contain one or more SQL statements separated by semicolons.
| Command | Description |
|---|---|
| ./migrate init | Create config file and migrations folder |
| ./migrate up | Run all pending migrations |
| ./migrate status | Show applied vs pending migrations |
| ./migrate help | Show usage |
migrate creates this table automatically:
CREATE TABLE schema_history (
id INT AUTO_INCREMENT PRIMARY KEY,
version INT NOT NULL UNIQUE,
filename VARCHAR(255) NOT NULL,
applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
success TINYINT(1) NOT NULL DEFAULT 1
);╔═══════════════════════════════╗ ║ cpp-migrate v1.0.0 ║ ║ MySQL Migration Tool ║ ╚═══════════════════════════════╝ [OK] Connected to MySQL database: myapp @ 127.0.0.1:3306 [INFO] Found 2 pending migration(s). --> Applying: 002_add_user_profile.sql ... OK --> Applying: 003_create_posts.sql ... OK [OK] Applied 2 migration(s) successfully.
Please do NOT report security vulnerabilities through public GitHub Issues.
If you discover a security vulnerability in this feature, please report it responsibly by emailing:
PRs and issues are welcome! This tools is built to help the Cambodian developer community.
| Back | FazBrowse Home | New Git URL |