bsovran opened a new pull request, #41200:
URL: https://github.com/apache/superset/pull/41200

   ### SUMMARY
   
   Adds a nullable `extra` column to the `slices` table (and the `Slice` model) 
to store open-ended, structured chart metadata, mirroring the long-standing 
dataset `extra` pattern.
   
   Charts currently have no extensible metadata field. `description` is 
unsuitable because it is user-facing prose rendered as markdown and shown as a 
tooltip in the Charts list. Datasets already solve this with an `extra` 
JSON-bearing column (`SqlaTable.extra`), and columns/metrics have their own 
`extra` as well. This change brings the same proven, low-risk pattern to charts.
   
   Design decisions:
   - Column name `extra`, consistent with `tables.extra` and column/metric 
`extra`.
   - Type `MediumText` (`superset.utils.core.MediumText`), which resolves to 
`TEXT` on Postgres/SQLite and `MEDIUMTEXT` on MySQL. This matches the existing 
JSON-bearing chart fields `params` and `query_context`, avoids MySQL's 64KB 
`TEXT` limit, and stores identical bytes across backends (unlike a native JSON 
column, which MySQL normalizes/reorders).
   - Nullable, no server default. JSON is stored as a string and parsed at the 
application layer, exactly as `SqlaTable.extra_dict` does today.
   - Added `extra` to `Slice.export_fields` so it round-trips through 
import/export.
   
   This PR intentionally scopes to the model + migration foundation. Exposing 
`extra` through the chart REST API (`ChartPostSchema`/`ChartPutSchema`/response 
schema) and any UI can follow in a separate PR.
   
   Associated SIP: https://github.com/apache/superset/issues/41171
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - backend schema change with no UI surface in this PR.
   
   ### TESTING INSTRUCTIONS
   
   1. Run `superset db upgrade` and confirm the `extra` column is added to 
`slices` (nullable).
   2. Run `superset db downgrade` and confirm the column is cleanly removed.
   3. Confirm `superset db heads` reports a single head.
   4. Set/read `Slice.extra` (e.g. via shell) and confirm round-trip through 
chart export/import.
   
   The migration uses the idempotent `add_columns`/`drop_columns` helpers from 
`superset/migrations/shared/utils.py`, following the exact shape of the 
existing `94e7a3499973` (add `folders` to datasets) migration. 
Upgrade/downgrade of the additive column was exercised against a local metadata 
DB.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: https://github.com/apache/superset/issues/41171
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [x] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [x] Migration is atomic, supports rollback & is backwards-compatible
     - [x] Confirm DB migration upgrade and downgrade tested
     - [x] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   Runtime/downtime: adding a nullable column to `slices` is a metadata-only 
DDL change on Postgres (no table rewrite, no default backfill) and completes 
near-instantly; no downtime expected. MySQL 8 performs this as an INSTANT add 
for a nullable column.
   
   Made with [Cursor](https://cursor.com)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to