1.2 KiB
1.2 KiB
Database Migration with Atlas
This project uses Atlas for database schema management and migrations.
📋 Prerequisites
-
Download and Install Atlas CLI
Run the following command in PowerShell or Git Bash:curl -sSf https://atlasgo.sh | shVerify installation:
atlas version -
Install GORM Provider Run inside your Go project:
go get -u ariga.io/atlas-provider-gorm -
Create atlas.hcl configuration file Just create an atlas.hcl file in your project root as example given at atlas.hcl.example
-
Create migrations folder
mkdir migrations -
Usage You can use the provided Makefile for common commands:
Generate a migration diff
make diffApply migrations
make applyCompute schema hash
make hashIf you don’t have make installed, you can run the Atlas commands directly:
atlas migrate diff --env gormatlas migrate apply --env gormatlas migrate hash