Skip to main content

Announcing the Atlas HCL VSCode Extension

· 3 min read

Introduction

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.

Features

Auto Completion

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.

Completion

Batch Completion

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).

Referencing Qualified Tables

Linting

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.

Linting

Usage

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.

Extension

After installing the Atlas HCL extension, it automatically registers for all the languages that Atlas supports. These languages include:

NameLanguage IDDescription
Atlas SQLiteatlas-schema-sqliteSQLite dialect
Atlas MySQLatlas-schema-mysqlMySQL dialect
Atlas PostgresQLatlas-schema-postgresqlPostgresQL dialect
Atlas MariaDBatlas-schema-mariadbMariaDB dialect
Atlas Config Fileatlas-configProject 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:

  1. Click on "Change Language" for your schema files in this section at bottom. (See image below)

Installation

  1. Use the Command Palette and choose "Change language mode" (See image below)

Installation by command palette

  1. Use Language Identifiers

Wrapping Up

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.

What next?