separate atlas command

This commit is contained in:
dpurbosakti
2025-09-12 08:57:05 +07:00
parent dfaf6e8d29
commit 20bc8419d0
10 changed files with 155 additions and 130 deletions
+59
View File
@@ -0,0 +1,59 @@
# Database Migration with Atlas
This project uses [Atlas](https://atlasgo.io/) for database schema management and migrations.
## 📋 Prerequisites
1. **Download and Install Atlas CLI**
Run the following command in PowerShell or Git Bash:
```sh
curl -sSf https://atlasgo.sh | sh
```
Verify installation:
```sh
atlas version
```
2. Install GORM Provider
Run inside your Go project:
```sh
go get -u ariga.io/atlas-provider-gorm
```
3. Create atlas.hcl configuration file
Just create an atlas.hcl file in your project root as example given at atlas.hcl.example
4. Create migrations folder
```sh
mkdir migrations
```
5. Usage
You can use the provided Makefile for common commands:
Generate a migration diff
```sh
make diff
```
Apply migrations
```sh
make apply
```
Compute schema hash
```sh
make hash
```
If you dont have make installed, you can run the Atlas commands directly:
```sh
atlas migrate diff --env gorm
```
```sh
atlas migrate apply --env gorm
```
```sh
atlas migrate hash
```