The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
## Workspaces: workspace + workspace_database tables, plus the table_remapping table
## used by the QP middleware to redirect production-table reads into a workspace's
## isolation schema.
databaseChangeLog:
- logicalFilePath: migrations/062_update_migrations.yaml
- changeSet:
id: v62.2026-04-21T12:00:00
author: bcm
comment: Create table_remapping table for workspace table-to-table remapping
changes:
- createTable:
tableName: table_remapping
remarks: Maps production tables to workspace tables for query remapping
columns:
- column:
name: id
type: int
remarks: Unique ID
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: database_id
type: int
remarks: Database this remapping applies to
constraints:
nullable: false
- column:
name: from_db
type: varchar(254)
remarks: Source database/project (top-level identifier; e.g. BigQuery project, ClickHouse db). Empty string when driver does not emit this level.
defaultValue: ""
constraints:
nullable: false
- column:
name: from_schema
type: varchar(254)
remarks: Source schema name. Empty string for schema-less drivers.
defaultValue: ""
constraints:
nullable: false
- column:
name: from_table_name
type: varchar(254)
remarks: Source table name
constraints:
nullable: false
- column:
name: to_db
type: varchar(254)
remarks: Target database/project (top-level identifier). Empty string when driver does not emit this level.
defaultValue: ""
constraints:
nullable: false
- column:
name: to_schema
type: varchar(254)
remarks: Target schema name. Empty string for schema-less drivers.
defaultValue: ""
constraints:
nullable: false
- column:
name: to_table_name
type: varchar(254)
remarks: Target table name
constraints:
nullable: false
- column:
name: created_at
type: ${timestamp_type}
remarks: When this remapping was created
defaultValueComputed: current_timestamp
constraints:
nullable: false
- changeSet:
id: v62.2026-04-21T12:00:01
author: bcm
comment: Add unique constraint on (database_id, from_db, from_schema, from_table_name)
## This constraint's leading column is `database_id`, so MySQL reuses its index
## to satisfy the FK added below — no separate `idx_..._database_id` needed.
changes:
- addUniqueConstraint:
tableName: table_remapping
constraintName: idx_unique_table_remapping_source
columnNames: database_id, from_db, from_schema, from_table_name
- changeSet:
id: v62.2026-04-21T12:00:02
author: bcm
comment: Add unique constraint on (database_id, to_db, to_schema, to_table_name) to prevent two source tables mapping to the same target
changes:
- addUniqueConstraint:
tableName: table_remapping
constraintName: idx_unique_table_remapping_target
columnNames: database_id, to_db, to_schema, to_table_name
- changeSet:
id: v62.2026-04-21T12:00:03
author: bcm
comment: Add foreign key on table_remapping(database_id)
## Added after the unique constraints so MySQL can satisfy the FK index
## requirement using the source-side unique index (whose leading column is
## `database_id`) instead of auto-creating a duplicate.
changes:
- addForeignKeyConstraint:
baseTableName: table_remapping
baseColumnNames: database_id
referencedTableName: metabase_database
referencedColumnNames: id
constraintName: fk_table_remapping_database_id
deleteCascade: true
- changeSet:
id: v62.2026-04-22T12:00:00
author: eric
comment: Create workspace table
changes:
- createTable:
tableName: workspace
remarks: Groups one or more databases with override credentials and per-database schema config
columns:
- column:
name: id
type: int
remarks: Unique ID
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: name
type: varchar(254)
remarks: Display name of the workspace
constraints:
nullable: false
- column:
name: creator_id
type: int
remarks: User who created this workspace
constraints:
nullable: true
- column:
name: created_at
type: ${timestamp_type}
remarks: When this workspace was created
defaultValueComputed: current_timestamp
constraints:
nullable: false
- column:
name: updated_at
type: ${timestamp_type}
remarks: When this workspace was last updated
defaultValueComputed: current_timestamp
constraints:
nullable: false
- changeSet:
id: v62.2026-04-22T12:00:01
author: eric
comment: Create workspace_database table
changes:
- createTable:
tableName: workspace_database
remarks: Associates a workspace with a database, with override credentials and schema config
columns:
- column:
name: id
type: int
remarks: Unique ID
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: workspace_id
type: int
remarks: The workspace this row belongs to
constraints:
nullable: false
- column:
name: database_id
type: int
remarks: The underlying database this row configures
constraints:
nullable: false
- column:
name: database_details
type: ${text.type}
remarks: JSON-encoded override connection details
constraints:
nullable: false
- column:
name: output_namespace
type: varchar(254)
remarks: Driver-opaque namespace string where workspace output tables are written (schema on Postgres-shaped drivers, database name on MySQL)
constraints:
nullable: false
- column:
name: input_schemas
type: ${text.type}
remarks: JSON array of input schema names
constraints:
nullable: false
- column:
name: status
type: varchar(20)
defaultValue: unprovisioned
remarks: Provisioning state
constraints:
nullable: false
- column:
name: created_at
type: ${timestamp_type}
remarks: When this row was created
defaultValueComputed: current_timestamp
constraints:
nullable: false
- column:
name: updated_at
type: ${timestamp_type}
remarks: When this row was last updated
defaultValueComputed: current_timestamp
constraints:
nullable: false
- changeSet:
id: v62.2026-04-22T12:00:02
author: eric
comment: FK workspace.creator_id -> core_user.id (set null on delete so deleting a user doesn't cascade)
changes:
- addForeignKeyConstraint:
baseTableName: workspace
baseColumnNames: creator_id
referencedTableName: core_user
referencedColumnNames: id
constraintName: fk_workspace_creator_id
onDelete: SET NULL
- changeSet:
id: v62.2026-04-22T12:00:03
author: eric
comment: Unique constraint on workspace_database (workspace_id, database_id)
changes:
- addUniqueConstraint:
tableName: workspace_database
constraintName: idx_unique_workspace_database
columnNames: workspace_id, database_id
- changeSet:
id: v62.2026-04-22T12:00:04
author: eric
comment: FK workspace_database.workspace_id -> workspace.id (cascade on delete)
changes:
- addForeignKeyConstraint:
baseTableName: workspace_database
baseColumnNames: workspace_id
referencedTableName: workspace
referencedColumnNames: id
constraintName: fk_workspace_database_workspace_id
deleteCascade: true
- changeSet:
id: v62.2026-04-22T12:00:05
author: eric
comment: FK workspace_database.database_id -> metabase_database.id (restrict on delete)
changes:
- addForeignKeyConstraint:
baseTableName: workspace_database
baseColumnNames: database_id
referencedTableName: metabase_database
referencedColumnNames: id
constraintName: fk_workspace_database_database_id
onDelete: RESTRICT
- changeSet:
id: v62.2026-04-22T12:00:06
author: eric
comment: Index workspace_database.workspace_id for hydration lookups
changes:
- createIndex:
tableName: workspace_database
indexName: idx_workspace_database_workspace_id
columns:
- column:
name: workspace_id
## No-op rollback: after any later ALTER TABLE on workspace_database, H2
## re-binds fk_workspace_database_workspace_id to this index, so the
## auto-generated DROP INDEX fails and aborts the whole downgrade. Any
## rollback that crosses this changeset also rolls back the createTable
## below, which removes the index with the table.
rollback: []