Skip to content

Commit

Permalink
Migration to add trashed_from_*
Browse files Browse the repository at this point in the history
We want to record where things were trashed *from* for two purposes:

- first, we want to be able to put things back if they're "untrashed".

- second, we want to be able to enforce permissions *as if* something is
still in its previous location. That is, if we trash a card or a
dashboard from Collection A, the permissions of Collection A should
continue to apply to the card or dashboard (e.g. in terms of who can
view it).

To achieve this, collections get a `trashed_from_location` (paralleling
their `location`) and dashboards/cards get a
`trashed_from_collection_id` (paralleling their `collection_id`).
  • Loading branch information
johnswanson committed Apr 17, 2024
1 parent a2cdc13 commit 6119797
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions resources/migrations/001_update_migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6188,6 +6188,51 @@ databaseChangeLog:
- customChange:
class: "metabase.db.custom_migrations.BackfillQueryField"

- changeSet:
id: v2024-04-12T13:24:09
author: johnswanson
comment: Add `collection.trashed_from_location`
changes:
- addColumn:
tableName: collection
columns:
- column:
name: trashed_from_location
type: text
remarks: "The previous location this collection was trashed from"
constraints:
nullable: true

- changeSet:
id: v2024-04-12T13:43:12
author: johnswanson
comment: Add `report_card.trashed_from_collection_id`
changes:
- addColumn:
tableName: report_card
columns:
- column:
name: trashed_from_collection_id
type: int
remarks: "The previous parent collection this card was trashed *from*"
constraints:
nullable: true

- changeSet:
id: v2024-04-12T13:43:20
author: johnswanson
comment: Add `report_dashboard.trashed_from_collection_id`
changes:
- addColumn:
tableName: report_dashboard
columns:
- column:
name: trashed_from_collection_id
type: int
remarks: "The previous parent collection this dashboard was trashed *from*"
constraints:
nullable: true

# >>>>>>>>>> DO NOT ADD NEW MIGRATIONS BELOW THIS LINE! ADD THEM ABOVE <<<<<<<<<<

########################################################################################################################
Expand Down

0 comments on commit 6119797

Please sign in to comment.