Skip to main content

Bob Gen for Atlas

Generates an ORM based on Atlas HCL schema files

Usage

# With env variable
ATLAS_DIALECT=psql go run github.com/stephenafamo/bob/gen/bobgen-atlas@latest

# With configuration file
go run github.com/stephenafamo/bob/gen/bobgen-atlas@latest -c ./config/bobgen.yaml

Driver Configuration

The configuration for the atlas driver must be prefixed by the driver name. You must use a configuration file or environment variables for configuring the database driver.

In the configuration file for atlas for example you would do:

atlas:
dialect: psql

When you use an environment variable it must also be prefixed by the driver name:

ATLAS_DIALECT=psql

The values that exist for the drivers:

NameDescriptionDefault
dialectDatabase dialect to use (REQUIRED)
dirPath to directory containing schema files.
shared_schemaSchema to not include prefix in modelfirst schema found
outputFolder for generated files"models"
pkgnamePackage name for generated code"models"
onlyOnly generate these
exceptSkip generation for these

Example of Only/Except:

atlas:
# Removes public.migrations table, the name column from the addresses table, and
# secret_col of any table from being generated. Foreign keys that reference tables
# or columns that are no longer generated may cause problems.
except:
public.migrations:
public.addresses:
- name
"*":
- secret_col