Code Monkey home page Code Monkey logo

atlas's Introduction

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

atlas's People

Contributors

lynhan318 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.