Skip to main content

Generate and update dbt schema.yml files from a template, manifest, and database

Project description

dbt-schemify

Generate and update dbt schema.yml files automatically from a template, your dbt manifest, and live database columns.

How it works

Three sources are merged in priority order (highest first):

  1. Existing schema.yml — values already there are never overwritten
  2. manifest.json — fills fields marked with the schemify sentinel
  3. .schemify.yml template — defines which fields to include and their static defaults

The sentinel value schemify in the template means "auto-populate this field from the manifest or database".

Installation

pip install dbt-schemify

With your database adapter:

pip install "dbt-schemify[snowflake]"
pip install "dbt-schemify[postgres]"
pip install "dbt-schemify[bigquery]"
pip install "dbt-schemify[duckdb]"

Quick start

1. Create a .schemify.yml template in your dbt project root:

version: '1.0'
models:
  - name: schemify
    description: schemify      # filled from manifest
    meta:
      owner: analytics         # static default applied to all models
    config:
      enabled: true            # static default
    columns:
      - name: schemify
        data_type: schemify    # filled from DB
        description: schemify  # left empty for humans to fill in
        meta:
          gdpr_tags: schemify

2. Compile your dbt project to get a manifest:

dbt compile

3. Run dbt-schemify:

dbt-schemify

Reads .schemify.yml, target/manifest.json, and ~/.dbt/profiles.yml automatically. Writes schema.yml next to each model's SQL file.

Usage

dbt-schemify [options]

Options:
  --schema PATH          Write all models into a single schema.yml at PATH.
                         If omitted, a schema.yml is created next to each model's SQL file.
  --manifest PATH        Path to manifest.json
                         Default: <project-dir>/target/manifest.json
  --template PATH        Path to .schemify.yml template
                         Default: <project-dir>/.schemify.yml
  --project-dir DIR      dbt project root. Default: current directory
  --profile NAME         dbt profile name. Default: read from dbt_project.yml
  --target NAME          dbt target (e.g. dev, prod). Default: profile default
  --profiles-dir DIR     Directory containing profiles.yml. Default: ~/.dbt/
  -s / --select          Filter models by name or tag. Space-separated.
                         Examples: -s orders   -s tag:marketing   -s tag:finance orders
  --each                 Write one <model_name>.yml per model instead of one schema.yml per folder
  --no-db                Skip database connection; no column fetching

Examples

# Auto-discover: write schema.yml next to every model's SQL file
dbt-schemify

# Only models with a specific tag (one schema.yml per directory)
dbt-schemify -s tag:marketing

# Only specific models by name
dbt-schemify -s orders customers

# Mix names and tags
dbt-schemify -s tag:finance orders

# All matching models into one explicit file
dbt-schemify --schema models/marketing/schema.yml -s tag:marketing

# One file per model named after the model (e.g. orders.yml, customers.yml)
dbt-schemify --each

# Without DB connection (manifest data only)
dbt-schemify --no-db

# Custom paths
dbt-schemify \
  --manifest target/manifest.json \
  --template .schemify.yml

Merge rules

Situation Result
Field exists in schema.yml Kept as-is
Field is schemify sentinel + value in manifest Filled from manifest
Field is schemify sentinel + column data_type Filled from DB
Field has a static value in template Used as default
Field not in template Not included in output
Column in DB but not in existing schema Added using template column structure
Column in existing schema but not in DB Preserved

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_schemify-0.2.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_schemify-0.2.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file dbt_schemify-0.2.0.tar.gz.

File metadata

  • Download URL: dbt_schemify-0.2.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for dbt_schemify-0.2.0.tar.gz
Algorithm Hash digest
SHA256 393bf5eab58063a0451f5dd2769659326d2514b1e16495989abf18db9d8d4383
MD5 536c8069149410adc9b1ff39c6d79457
BLAKE2b-256 ee3c896af708b7959f908a685d963d94690cc44dc07c1dd8f52e56f99a1368fb

See more details on using hashes here.

File details

Details for the file dbt_schemify-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dbt_schemify-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for dbt_schemify-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edb06b558f6ab9b79f625b3be918e62f2d56381be641966a22dfeb89f6badf6f
MD5 ad2be5e261ba450d37da2a5ff174ecbc
BLAKE2b-256 9f6d09c84afefe513e91ac4f0d3238f4df244c90e4f5c0e003e60a7be0397c3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page