forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename collection revision (metabase#15616)
* Table collection_revision -> collection_permission_graph_revision in anticipation of getting collection revisions in, need the table name as the previous table named this was tracking changes to the permission graph * rename collection permission graph revision alias * Remove unnecessary or for precondition * Rename sequence in sql liquibase has a renameSequence changeset but it doesn't work for h2 obviously. However, it doesn't allow this constraint to be honored with a precondition. Just having this changeset on h2 blows up
- Loading branch information
Showing
6 changed files
with
49 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
src/metabase/models/collection_revision.clj → .../collection_permission_graph_revision.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
(ns metabase.models.collection-revision | ||
(ns metabase.models.collection-permission-graph-revision | ||
(:require [metabase.util :as u] | ||
[metabase.util.i18n :refer [tru]] | ||
[toucan.db :as db] | ||
[toucan.models :as models])) | ||
|
||
(models/defmodel CollectionRevision :collection_revision) | ||
(models/defmodel CollectionPermissionGraphRevision :collection_permission_graph_revision) | ||
|
||
(defn- pre-insert [revision] | ||
(assoc revision :created_at :%now)) | ||
|
||
(u/strict-extend (class CollectionRevision) | ||
(u/strict-extend (class CollectionPermissionGraphRevision) | ||
models/IModel | ||
(merge models/IModelDefaults | ||
{:types (constantly {:before :json | ||
:after :json}) | ||
:pre-insert pre-insert | ||
:pre-update (fn [& _] (throw (Exception. (tru "You cannot update a CollectionRevision!"))))})) | ||
:pre-update (fn [& _] (throw (Exception. (tru "You cannot update a CollectionPermissionGraphRevision!"))))})) | ||
|
||
|
||
(defn latest-id | ||
"Return the ID of the newest `CollectionRevision`, or zero if none have been made yet. | ||
"Return the ID of the newest `CollectionPermissionGraphRevision`, or zero if none have been made yet. | ||
(This is used by the collection graph update logic that checks for changes since the original graph was fetched)." | ||
[] | ||
(or (:id (db/select-one [CollectionRevision [:%max.id :id]])) | ||
(or (:id (db/select-one [CollectionPermissionGraphRevision [:%max.id :id]])) | ||
0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters