Atlas supports many ways to describe database schemas. Using Schema Loaders, Atlas gives users the flexibility to define schemas using plain SQL, a connection to another database or using Atlas HCL.
What is Atlas HCL?
Atlas includes a data-definition language based on a Terraform-like syntax. This language, which was designed specifically for describing database schemas is based on HashiCorp's HCL toolkit for creating structured configuration languages.
This data definition language is easy to read, edit, and visualize, and it allows us to organize our schema data in a efficient way that has many benefits to using plain SQL.
What is the Atlas HCL VSCode Extension?
To make it easier for users to define schemas using Atlas HCL, we're happy to announce the release of the official Atlas HCL VSCode Extension. This extension provides a rich set of features that will help users define schemas using Atlas HCL.
In this post, we'll take a closer look at the features of this extension and how it can benefit your work.
The extension provides auto completion support for all SQL resources available within Atlas. For a comprehensive list of the supported resources, please visit this document: SQL Resources.
Referencing Qualified Tables
This refers to a feature that allows for referencing tables and their columns in a structured manner, either relative to the current location (e.g. column.id) or absolute to the table (e.g. table.user.column.id).
To ensure that errors are caught from the beginning, the Atlas HCL VSCode Extension offers a range of validations that enhance type safety for users. The specific validations provided will vary depending on the SQL dialect being used. This feature is designed to help users identify and fix issues early on, resulting in a more efficient and effective schema-building process.
To use this extension, you can either install it directly from the VSCode desktop or download it from the Marketplace. The extension will appear in the extensions list as Atlas HCL.
After installing the Atlas HCL extension, it automatically registers for all the languages that Atlas supports. These languages include:
|Atlas SQLite||atlas-schema-sqlite||SQLite dialect|
|Atlas MySQL||atlas-schema-mysql||MySQL dialect|
|Atlas PostgresQL||atlas-schema-postgresql||PostgresQL dialect|
|Atlas MariaDB||atlas-schema-mariadb||MariaDB dialect|
|Atlas Config File||atlas-config||Project Configuration|
By default, the extension will auto-detect atlas.hcl files in your project. However, if you have any schema files in your project, you must choose the language for them. You can do this in three ways in vscode:
- Click on "Change Language" for your schema files in this section at bottom. (See image below)
- Use the Command Palette and choose "Change language mode" (See image below)
In this post, we've introduced The Atlas HCL Extension. There's much more inside, and we invite you to install it today and give it a try.
- Follow the Getting Started guide.
- Join our Discord Server.
- Follow us on Twitter.