Skip to main content

Oxygen sync

The oxyc sync command collects schema information from your databases and writes it into your repository, under .databases/, for use by agents and other Oxygen features. The files hold table structures, column names and types, and the DDL, which help agents understand your data model. Oxygen introspects the databases on the server, with the connection settings and secrets your deployed workspace has, and oxyc writes the files into your local checkout. No warehouse credentials are needed on your machine, only an oxyc login. Because the server reads the deployed config.yml, push a change to a database’s configuration before you sync it.
oxy sync has moved to oxyc sync; the old command was removed.

Command Overview

Install oxyc with npm i -g @oxy-hq/cli, sign in with oxyc login, and run the command from the root of your checkout.

Arguments

  • DATABASE_NAME (optional): The name of a specific database to sync, as defined in your config.yml file. If omitted, every database is synced, one at a time. --database <name> is the same.

Options

  • --workspace <id>: The workspace whose deployed configuration names the databases.
  • -d, --datasets <DATASET>: Sync only this dataset (schema) within the named database. Repeat it for more than one.
  • --tables <SCHEMA.TABLE>: Sync only this table within the named database. Repeat it for more than one.
  • -o, --overwrite: Overwrite existing files. By default, existing files are skipped.
  • --dry-run: Print what would be written, and write nothing.
  • --dir <path>: The checkout to write into. The default is the current directory.
  • --json: Print a machine-readable report of each database and each file.

Usage Examples

Sync All Databases

This syncs every database defined in your deployed config.yml. Existing files are skipped. If one database fails, the others still sync, and the command exits non-zero.

Sync a Specific Database

Sync Specific Datasets

This syncs only the “customers” and “orders” datasets from the “my_database” database.

Overwrite Existing Files

With -o, existing files are replaced, and a stale model file in a dataset’s models/ directory is removed. Files elsewhere under .databases/ are left alone.

Output and Warnings

  1. Skipped files: When a file already exists and overwrite mode is off (the default), it is listed as skipped.
  2. Overwritten and deleted files: With -o, the files replaced and the stale models removed are listed.
  3. Skipped databases: A database whose type cannot be synced (for example airhouse_managed) is skipped with a warning.
Exit codes: 0 success, 4 not signed in or not a workspace admin, 5 no such database or workspace, 6 the database cannot connect as configured, 7 a retryable failure (the warehouse failed, or the sync took too long: narrow it with -d).

Understanding the Synced Data

When you run oxyc sync, Oxygen will:
  1. Connect to each configured database
  2. Extract schema information, including tables, columns and data types
  3. Generate semantic models representing this data
  4. Write these models as files under .databases/ in your checkout:
    • .databases/<database>/<dataset>.sql: the dataset’s DDL, where the database exposes it
    • .databases/<database>/<dataset>/models/<table>.schema.yml: one file per table
These semantic files are then used by agents when you ask questions about your data, enabling them to generate accurate SQL queries and understand your data structure. Commit them like any other workspace file.

Configuration

Before using the sync command, ensure your databases are properly configured in your config.yml file, and that the configuration is deployed. For example:
Reference credentials through the workspace’s secrets (password_var, key_json_var): the server resolves them when it syncs. A connection that reads a file from the workspace (a key_path, a local DuckDB file) cannot be synced by the cloud. See the configuration documentation for more details on setting up your database connections.