Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions core-spec/v1/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ export-root/

### Entity Ownership and Containers

Every entity's logical position in the collection hierarchy is determined by its `collection_id` field, not the folder structure on disk. The folder layout is for human organization only; Metabase imports entities based solely on their `collection_id`.
> **Critical:** Every entity's logical position in the collection hierarchy is determined **exclusively** by its `collection_id` field, not the folder structure on disk. The folder layout is for human organization only; Metabase imports entities based solely on their `collection_id`. **An entity without `collection_id` (or with `collection_id: null`) will appear in the root collection.** If you want a card, dashboard, document, snippet, or transform to be inside a specific collection, you **must** set its `collection_id` to the `entity_id` of that collection. Cards nested under a dashboard or document **must also** set `collection_id` to match the `collection_id` of their parent dashboard or document. Similarly, subcollections **must** set `parent_id` to the `entity_id` of their parent collection — without `parent_id`, a collection is treated as a root-level collection regardless of its position in the directory tree.

Dashboards and documents act as **containers** for cards: a card with `dashboard_id` set is owned by that dashboard, and a card with `document_id` set is owned by that document. Container-owned cards behave as if the dashboard or document were a subcollection:

- **`collection_id`** — Places the entity in a collection. `null` means root collection. Must always be set, even when `dashboard_id` or `document_id` is set — it must match the `collection_id` of the parent dashboard or document.
- **`collection_id`** (**required for all collection items**) — Places the entity in a collection. `null` or omitted means root collection. **Must always be set** to place an entity in a specific collection. Even when `dashboard_id` or `document_id` is set, `collection_id` **must** be set and must match the `collection_id` of the parent dashboard or document.
- **`dashboard_id`** — Nests the card under a dashboard. The card should only be used within that dashboard. To reuse a card outside its dashboard, unset `dashboard_id` and place it directly in a collection.
- **`document_id`** — Nests the card under a document. Same semantics as `dashboard_id`: the card should only be used within that document.

Expand Down Expand Up @@ -2173,7 +2173,9 @@ target:

## Collection

A collection is a folder-like container for organizing cards, dashboards, and other entities. Collection hierarchy is reflected in the directory structure. Subcollections must set `parent_id` to the entity_id of their parent collection.
A collection is a folder-like container for organizing cards, dashboards, and other entities. Collection hierarchy is reflected in the directory structure.

> **Critical:** Subcollections **must** set `parent_id` to the `entity_id` of their parent collection. Without `parent_id`, a collection is treated as a root-level collection regardless of where its file is located on disk. All items inside a collection (cards, dashboards, documents, etc.) **must** set their `collection_id` to that collection's `entity_id` to appear within it.

### Schema

Expand All @@ -2189,7 +2191,7 @@ A collection is a folder-like container for organizing cards, dashboards, and ot
| `type` | string | No | `null` or `"instance-analytics"` |
| `namespace` | string | No | `null`, `"transforms"`, or `"snippets"` |
| `authority_level` | string | No | `null` or `"official"` |
| `parent_id` | string | No | Collection FK (entity_id of parent), `null` for root |
| `parent_id` | string | No | Collection FK (entity_id of parent). **Must** be set for subcollections; `null`/omitted = root-level collection |
| `personal_owner_id` | string | No | User FK (email) for personal collections |
| `is_sample` | boolean | No | Sample collection flag |
| `created_at` | string | No | ISO 8601 timestamp |
Expand Down Expand Up @@ -2242,11 +2244,11 @@ A card represents a Question, Model, or Metric in Metabase. Cards are the primar
| `archived` | boolean | No | Whether archived (default: `false`) |
| `archived_directly` | boolean | No | Archived directly vs. inherited |
| `type` | string | No | `"question"`, `"model"`, or `"metric"` |
| `collection_id` | string | No | Collection FK (entity_id) |
| `collection_id` | string | No | Collection FK (entity_id). **Set this to place the card in a collection**; `null`/omitted = root collection. When `dashboard_id` or `document_id` is set, must match the parent's `collection_id` |
| `collection_position` | integer | No | Position within collection |
| `collection_preview` | boolean | No | Show preview in collection (default: `true`) |
| `dashboard_id` | string | No | Dashboard FK (entity_id) |
| `document_id` | string | No | Document FK (entity_id) |
| `dashboard_id` | string | No | Dashboard FK (entity_id). Card's `collection_id` must match the dashboard's `collection_id` |
| `document_id` | string | No | Document FK (entity_id). Card's `collection_id` must match the document's `collection_id` |
| `table_id` | array | No | Table FK matching source-table in query |
| `source_card_id` | string | No | Card FK (entity_id) |
| `parameters` | array | No | Card parameters (see [Parameter](#parameter)) |
Expand Down Expand Up @@ -2315,7 +2317,7 @@ A dashboard is a collection of cards arranged in a grid layout. Dashboards conta
| `description` | string | No | Description |
| `archived` | boolean | No | Whether archived (default: `false`) |
| `archived_directly` | boolean | No | Archived directly vs. inherited |
| `collection_id` | string | No | Collection FK (entity_id) |
| `collection_id` | string | No | Collection FK (entity_id). **Set this to place the dashboard in a collection**; `null`/omitted = root collection |
| `collection_position` | integer | No | Position within collection |
| `position` | integer | No | Display position |
| `auto_apply_filters` | boolean | No | Auto-apply filter changes (default: `true`) |
Expand Down Expand Up @@ -2484,7 +2486,7 @@ Cards can be nested under a document via `card.document_id`, similar to how card
| `serdes/meta` | array | Yes | Identity path with `model: Document` |
| `content_type` | string | No | Always `"application/json+vnd.prose-mirror"` |
| `description` | string | No | Description |
| `collection_id` | string | No | Collection FK (entity_id) |
| `collection_id` | string | No | Collection FK (entity_id). **Set this to place the document in a collection**; `null`/omitted = root collection |
| `collection_position` | integer | No | Position within collection |
| `archived` | boolean | No | Whether archived (default: `false`) |
| `archived_directly` | boolean | No | Archived directly vs. inherited |
Expand Down Expand Up @@ -2744,7 +2746,7 @@ A snippet is a reusable SQL fragment that can be referenced in native queries us
| `serdes/meta` | array | Yes | Identity path with `model: NativeQuerySnippet` |
| `description` | string | No | Description |
| `archived` | boolean | No | Whether archived (default: `false`) |
| `collection_id` | string | No | Collection FK (entity_id) — snippets collection |
| `collection_id` | string | No | Collection FK (entity_id). **Set this to place the snippet in a snippet collection**; `null`/omitted = root snippet collection |
| `template_tags` | map | No | Template tag definitions (usually empty `{}`) |
| `created_at` | string | No | ISO 8601 timestamp |

Expand Down Expand Up @@ -2785,7 +2787,7 @@ The `source` defines how data is produced — either an MBQL/native query (`type
| `target` | object | Yes | Target table: `database` (Database FK), `type` (`"table"`), `schema`, `name` |
| `serdes/meta` | array | Yes | Identity path with `model: Transform` |
| `description` | string | No | Description |
| `collection_id` | string | No | Collection FK (entity_id) |
| `collection_id` | string | No | Collection FK (entity_id). **Set this to place the transform in a collection**; `null`/omitted = root collection |
| `tags` | array | No | Transform tags (see below) |
| `created_at` | string | No | ISO 8601 timestamp |

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Product Dashboard
entity_id: Q_jD-f-9clKLFZ2TfUG2h
collection_id: M-Q4pcV0qkiyJ0kiSWECl
creator_id: admin@example.com
parameters:
- id: c3d4e5f6-7890-abcd-ef12-34567890abcd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Product Overview
entity_id: f1C68pznmrpN1F5xFDj6d
collection_id: M-Q4pcV0qkiyJ0kiSWECl
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Top Products by Revenue
entity_id: FTxpeL9vY5pyb6Lc6lCDK
collection_id: M-Q4pcV0qkiyJ0kiSWECl
creator_id: admin@example.com
display: bar
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Arithmetic Expressions"
entity_id: 1O_2jSo2fD6m3Qr6My7aa
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Basic Aggregations"
entity_id: h5F2EjHsRd73Dqqh8sAtd
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Comparison Filters"
entity_id: 8kTL-8IzNdWMtXfaMPZaE
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Conditional Aggregations"
entity_id: irROiaJoSsiXPKGxwWvWY
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Conditional and Type Conversion"
entity_id: 1hsUzNOepulZo3Jamzd1R
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Cumulative and Statistical Aggregations"
entity_id: x61UtCMCuBNjw0TEFQeWG
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: line
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Fields and Expressions"
entity_id: fLdExPr3sS10nS0ExAmPl
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Geographic Filter (Inside)"
entity_id: bK64P6yr9_Nx-A8S3PqOZ
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: map
database_id: Sample Database
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/joins.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Joins - Strategies and Compound Conditions"
entity_id: wpW9JO5MsHQd0-7WrR7gN
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/math_functions.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Math Functions"
entity_id: jPrM-oh3r1BR42xSs4Ipj
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Metric, Measure, and Segment References"
entity_id: kBjQ5VXJ5z3vYSW72J6qa
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Native Query - Card and Snippet References"
entity_id: HiBFSt0BNx5s5MxVDLLKB
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Native Query - Field Filter and Temporal Unit"
entity_id: sk02d7sPWAk2TYH2Y7JhZ
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: line
database_id: Sample Database
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/native_variables.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Native Query - Variables"
entity_id: 2u10n8GV6u0LFYrq8yV5p
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/nested_query.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Nested Query"
entity_id: 1t9TE-8T-AlaM19nx3yQV
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Null, Empty, and String Filters"
entity_id: ZvHEBpdFQ-VSvem16KCkL
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Source Card Reference"
entity_id: gt4OaWYAuDWRHn5Irnd4h
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/string_functions.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "String Functions"
entity_id: HeLFZSVb4Jm25p4tWfVP9
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Temporal and Logical Filters"
entity_id: BMx-SlSPsSfGSKaEgOzn0
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Temporal Expressions"
entity_id: DBBrqcMAmOO0sbM_CzM_Z
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Temporal Extraction"
entity_id: bDK7jyPszEHzHh4aG4_SV
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Total Revenue
entity_id: IW8kbqZVaMxdGtCM2F4U6
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: scalar
type: metric
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/url_functions.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "URL Functions"
entity_id: uwAeNRHymXTD1G_7lWV1d
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
1 change: 1 addition & 0 deletions examples/v1/collections/main/queries/window_offset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Window Function - Offset"
entity_id: ErQY8K5Tep4xBc3VY_-1e
collection_id: cOlQuErIeS0ExAmPlE2x1
creator_id: admin@example.com
display: line
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Orders by Category (Stacked Bar)
entity_id: ciG63nSLHKRTImt5iWEte
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: bar
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Sales Funnel
entity_id: mkKa6jf-QsuCRnaPOIsYh
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: funnel
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Revenue Gauge
entity_id: GWrIQqjbzxysSCm8PLU5j
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: gauge
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Revenue Over Time (Line)
entity_id: UEWVldEEZ-3sYUjjN54qz
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: line
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Customer Locations (Map)
entity_id: CI61cHgBAKPBEDTxhK8X3
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: map
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Orders by Category (Pie)
entity_id: dYD1j3pQtJdctg8duByUL
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: pie
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Orders Pivot Table
entity_id: BjwHr6elEuKQuL26BEgno
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: pivot
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Total Revenue (Smart Scalar)
entity_id: bSj47tilPIkwDIewvMf8z
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: smartscalar
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Products Table (Formatted)
entity_id: Wo5d6IV8lb63wex29uh6H
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: table
database_id: Sample Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Monthly Revenue Changes (Waterfall)
entity_id: kJWYpTzyc9ow-75HjyIhf
collection_id: cOlViZsEtTiNgS0ExAmP1
creator_id: admin@example.com
display: waterfall
database_id: Sample Database
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metabase/representations",
"version": "1.1.0",
"version": "1.1.1",
"description": "Metabase representation format specification and schema validator",
"license": "SEE LICENSE IN LICENSE.txt",
"repository": {
Expand Down
Loading