Files
simrsx-be/cmd/satusehat-migration/README-ATLAS.MD
2025-09-12 08:57:05 +07:00

1.1 KiB
Raw Blame History

Database Migration with Atlas

This project uses Atlas for database schema management and migrations.

📋 Prerequisites

  1. Download and Install Atlas CLI
    Run the following command in PowerShell or Git Bash:

    curl -sSf https://atlasgo.sh | sh
    

    Verify installation:

    atlas version
    
  2. Install GORM Provider Run inside your Go project:

    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

    mkdir migrations
    
  5. Usage You can use the provided Makefile for common commands:

    Generate a migration diff

    make diff
    

    Apply migrations

    make apply
    

    Compute schema hash

    make hash
    

    If you dont have make installed, you can run the Atlas commands directly:

    atlas migrate diff --env gorm
    
    atlas migrate apply --env gorm
    
    atlas migrate hash