### Development Setup and Execution Source: https://github.com/metabase/database-metadata/blob/main/README.md Commands for setting up the development environment and running the CLI tool for extracting table metadata during development. ```sh bun install bun bin/cli.ts extract-table-metadata examples/v1/table_metadata.json /tmp/.metadata/databases ``` -------------------------------- ### Database YAML Example Source: https://github.com/metabase/database-metadata/blob/main/core-spec/v1/spec.md Example of a database entry in YAML format, specifying its name and engine. ```yaml name: Sample Database engine: postgres ``` -------------------------------- ### Table Schema Example Source: https://github.com/metabase/database-metadata/blob/main/core-spec/v1/spec.md Defines a table named 'ORDERS' with associated fields. Use this to represent database tables. ```yaml name: ORDERS db_id: Sample Database schema: PUBLIC description: Confirmed Sample Company orders for a product, from a user. fields: - name: ID base_type: type/BigInteger database_type: BIGINT semantic_type: type/PK - name: TOTAL description: The total billed amount. base_type: type/Float database_type: DOUBLE PRECISION ``` -------------------------------- ### Field Schema Example Source: https://github.com/metabase/database-metadata/blob/main/core-spec/v1/spec.md Describes a 'CREATED_AT' field, including its base type, database type, and semantic type. Use this for individual column definitions. ```yaml name: CREATED_AT description: The order creation timestamp. base_type: type/Text database_type: TEXT effective_type: type/DateTime semantic_type: type/CreationTimestamp coercion_strategy: Coercion/ISO8601->DateTime ``` -------------------------------- ### Nested Field Schema Example Source: https://github.com/metabase/database-metadata/blob/main/core-spec/v1/spec.md Illustrates a nested field using 'parent_id' to reference its enclosing field. This is used for JSON-unfolded columns. ```yaml name: name base_type: type/Text database_type: TEXT parent_id: - Sample Database - PUBLIC - EVENTS - DATA - user ``` -------------------------------- ### Recommended Metadata Management Workflow Source: https://github.com/metabase/database-metadata/blob/main/README.md This snippet demonstrates the recommended workflow for managing Metabase metadata. It involves creating a `.metadata/` directory, downloading the JSON, and then extracting it to YAML using the CLI. ```sh mkdir -p .metadata # Drop table_metadata.json from Metabase into .metadata/ rm -rf .metadata/databases bunx @metabase/database-metadata extract-table-metadata .metadata/table_metadata.json .metadata/databases ``` -------------------------------- ### Extract Specification to File using CLI Source: https://github.com/metabase/database-metadata/blob/main/README.md This command extracts the bundled specification to a specified file path. If the `--file` option is omitted, the spec will be written to `spec.md` in the current directory. ```sh bunx @metabase/database-metadata extract-spec --file ./spec.md ``` -------------------------------- ### Extract Table Metadata using CLI Source: https://github.com/metabase/database-metadata/blob/main/README.md Use this command to convert the downloaded `table_metadata.json` file into a human- and agent-friendly YAML tree structure. Specify the input JSON file and the output folder for the YAML files. ```sh bunx @metabase/database-metadata extract-table-metadata ``` -------------------------------- ### Metabase Metadata Export API Endpoint Source: https://github.com/metabase/database-metadata/blob/main/README.md This is a typical full export request to the Metabase API endpoint for fetching database metadata. It includes all sections: databases, tables, and fields. ```http POST /api/ee/serialization/metadata/export?with-databases=true&with-tables=true&with-fields=true ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.