Skip to content

ThangSuperMan/atlas

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atlas-template

A template repo for using Atlas.

Getting started

Quick installation

macOS + Linux:

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

Homebrew:

brew install ariga/tap/atlas

Docker:

docker pull arigaio/atlas

Click here to read instructions for other platforms.

Creating a container image

This repo comes with a bootstrapped Dockerfile to package the migrations as a container image.

Build the container image:

docker build -t atlas:local .

Common actions

This repo comes with preconfigured atlas.hcl that defines a local MySQL-based dev environment named "local" which you can reference using the --env local flag.

Plan a new migration

Modify the desired schema of your database schema.hcl:

schema "app" {

}

table "users" {
  schema = schema.app
  column "id" {
    type = int
  }
  column "user_name" {
    type = varchar(255)
    unique = true
  }
  column "email" {
    type = varchar(255)
    unique = true
  }
+  column "bio" {
+    type = text
+    unique = true
+  }
  primary_key {
    columns = [column.id]
  }
}

Automatically generate a migration file:

atlas migrate diff --env local

To learn more about defining database schemas in HCL, check out the SQL resource documentation.

Apply a migration

Apply the migration directory to your database:

atlas migrate apply --env local -u "mysql://root:pass@database-url:3306/app"

Lint the migration directory

Verify the latest migration file in the directory is safe to apply:

atlas migrate lint --env local --latest 1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 92.5%
  • Dockerfile 7.5%