github ariga/atlas v0.4.1

latest releases: v0.28.1, v0.28.0, v0.27.0...
2 years ago

Atlas v0.4.1 is a patch release that includes small improvements and introduces support for Project Files.

Installation

MacOS

curl -LO https://release.ariga.io/atlas/atlas-darwin-amd64-v0.4.1
chmod +x ./atlas-darwin-amd64-v0.4.1
sudo mv ./atlas-darwin-amd64-v0.4.1 /usr/local/bin/atlas
sudo chown root: /usr/local/bin/atlas

Linux

curl -LO https://release.ariga.io/atlas/atlas-linux-amd64-v0.4.1
sudo install -o root -g root -m 0755 ./atlas-linux-amd64-v0.4.1 /usr/local/bin/atlas

Windows

Download

Docker

docker pull arigaio/atlas:0.4.1
docker run --rm -p 5800:5800 arigaio/atlas:0.4.1

New Features

In this version, we added a new concept called project files. Project files provide a way to describe and interact with multiple environments while working with Atlas. A project file is a file named atlas.hcl and it contains multiple env blocks, each describing an environment. Each environment has a reference to where the schema definition file resides, a database URL and an array of the schemas in the database that are managed by Atlas.

// Define an environment named "local"
env "local" {
  // Declare where the schema definition file resides.
  src = "./schema/project.hcl"
  
  // Define the URL of the database which is managed in
  // this environment.
  url = "mysql://localhost:3306"
  
  // Define the URL of the Dev Database for this environment
  // See: https://atlasgo.io/dev-database
  dev = "mysql://localhost:3307"
  
  // The schemas in the database that are managed by Atlas.
  schemas = ["users", "admin"]
}

env "dev" {
  // ... a different env
}

Environments may also declare a migration_dir block to configure how versioned migrations work in the specific environment.

env "local" {
    // ..
    migration_dir {
        // URL where the migration directory resides. Only filesystem directories
        // are currently supported but more options will be added in the future.
        url = "file://migrations"
        // Format of the migration directory: atlas | flyway | liquibase | goose | golang-migrate
        format = atlas
    }
}

That way, when running atlas migrate commands, the environment can be worked against using the --env flag.

atlas migrate validate --env local

Project files can also pass and declare input values.

env "local" {
  url = "sqlite://test?mode=memory&_fk=1"
  src = "./schema.hcl"
  
  // Other attributes are passed as input values to "schema.hcl":
  tenant = "rotemtam"
}

These values can then be consumed by variables defined in the schema file:

variable "tenant" {
  type = string
}
schema "main" {
  name = var.tenant
}

For a more thorough explanation and examples of the new project files, click here.

What's Changed

  • internal/integration: testscript for migration dirs by @rotemtam in #790
  • sql/sqlite: simple file lock to implement schema.Locker for SQLite by @masseelch in #791
  • cmd/atlascmd: move and fix test for version command and build by @masseelch in #792
  • cmd/atlascmd: acquire a lock before executing migrations by @masseelch in #781
  • sql/migrate: introduce basic execution logging by @masseelch in #793
  • doc/website: add Algolia search bar by @hedwigz in #794
  • doc/md: update UI docs by @hilakashai in #800
  • sql/sqlclient: expose registered name by @masseelch in #796
  • Update README.md by @hilakashai in #802
  • sql/mysql: Attempt a fix for RawExpr cases by @ofpiyush in #797
  • doc/md: update UI command docs by @hilakashai in #801
  • cmd/atlas: avoid printing help messages on Run errors by @a8m in #804
  • cmd/atlascmd: env support for migrate commands by @rotemtam in #799
  • sql/mysql: move charset writing to data_type stage by @a8m in #806
  • cmd/atlas: support input variables for project files by @rotemtam in #807

New Contributors

Full Changelog: v0.4.0...v0.4.1

Legal

The binaries distributed in this release are released under the Ariga End User License. If you would like to build Atlas from source follow the instructions here.

Don't miss a new atlas release

NewReleases is sending notifications on new releases.