GoSMM
Golang Simple Migration Manager

Overview
GoSMM is a simple yet powerful SQL migration manager written in Go. This library enables you to manage SQL database migrations for multiple database drivers including Postgres, MySQL, and SQLite3.
The GoSMM package allows you to perform tasks like:
- Checking migration integrity.
- Executing migration files in order.
- Creating migration history tables.
Installation
To get started, you can install GoSMM using go get:
```bash
go get github.com/k1e1n04/gosmm
```
Usage
Configuration
```go
config := gosmm.DBConfig{
Driver: os.Getenv("DB_DRIVER"),
Host: os.Getenv("DB_HOST"),
Port: os.Getenv("DB_PORT"),
User: os.Getenv("DB_USER"),
Password: os.Getenv("DB_PASSWORD"),
DBName: os.Getenv("DB_NAME"),
}
```
Fields:
Driver: Database driver ("postgres", "mysql", or "sqlite3").
Host: Hostname of your database.
Port: Port number for the database.
User: Username for the database.
Password: Password for the database.
DBName: The name of the database.
To perform migrations, use the Migrate function:
```go
db, err := gosmm.Connect(config)
if err != nil {
log.Fatalf("Connection failed: %v", err)
}
err := gosmm.Migrate(db, os.Getenv("MIGRATIONS_DIR"))
if err != nil {
log.Fatalf("Migration failed: %v", err)
}
```
This will:
- Connect to the database.
- Validate the DB configuration.
- Check migration integrity.
- Execute pending migrations.
How to Contribute
Contributions are welcome! Feel free to submit a pull request on GitHub.
License
This project is licensed under the MIT License.
Disclaimer
Please make sure to back up your database before running migrations. The maintainers are not responsible for any data loss.