Skip to content
Snippets Groups Projects
Unverified Commit fac6ff5e authored by Cam Saül's avatar Cam Saül
Browse files

Remove unused tables and columns :boom:

parent 8f7a847c
No related branches found
No related tags found
No related merge requests found
databaseChangeLog:
- changeSet:
id: 42
author: camsaul
changes:
- dropColumn:
tableName: query_queryexecution
columnName: query_id
- dropColumn:
tableName: core_user
columnName: is_staff
- dropColumn:
tableName: metabase_database
columnName: organization_id
- dropColumn:
tableName: report_card
columnName: organization_id
- dropColumn:
tableName: report_dashboard
columnName: organization_id
- dropTable:
tableName: annotation_annotation
- dropTable:
tableName: core_permissionsviolation
- dropTable:
tableName: core_userorgperm
- dropTable:
tableName: core_organization
- dropTable:
tableName: metabase_foreignkey
- dropTable:
tableName: metabase_tablesegment
- dropTable:
tableName: query_query
- dropTable:
tableName: report_dashboardsubscription
- dropTable:
tableName: report_emailreport_recipients
- dropTable:
tableName: report_emailreportexecutions
- dropTable:
tableName: report_emailreport
......@@ -22,9 +22,6 @@
(defentity ^:private DataMigrations :data_migrations)
;; This is defined here since we still need it for some of the data migrations below. It's no longer used.
(defentity ^:deprecated ^:private ForeignKey :metabase_foreignkey)
(defn- migration-ran? [migration-name]
(db/exists? DataMigrations :id (name migration-name)))
......@@ -108,17 +105,6 @@
(db/delete! Activity :topic "database-sync")))
;; Clean up duplicate FK entries
(defmigration remove-duplicate-fk-entries
(let [existing-fks (db/select ForeignKey)
grouped-fks (group-by #(str (:origin_id %) "_" (:destination_id %)) existing-fks)]
(doseq [[k fks] grouped-fks]
(when (< 1 (count fks))
(log/debug "Removing duplicate FK entries for" k)
(doseq [duplicate-fk (drop-last fks)]
(db/delete! ForeignKey, :id (:id duplicate-fk)))))))
;; Migrate dashboards to the new grid
;; NOTE: this scales the dashboards by 4x in the Y-scale and 3x in the X-scale
(defmigration update-dashboards-to-new-grid
......@@ -173,15 +159,6 @@
(recur more (+ row-target (:sizeY bad-card)))))))))
;; migrate FK information from old ForeignKey model to Field.fk_target_field_id
(defmigration migrate-fk-metadata
(when (> 1 (db/select-one-count Field :fk_target_field_id [:not= nil]))
(when-let [fks (not-empty (db/select ForeignKey))]
(doseq [{:keys [origin_id destination_id]} fks]
(db/update! Field origin_id
:fk_target_field_id destination_id)))))
;; populate RawTable and RawColumn information
;; NOTE: we only handle active Tables/Fields and we skip any FK relationships (they can safely populate later)
(defmigration create-raw-tables
......
......@@ -85,7 +85,7 @@
response-unauthentic)))
(def ^:private current-user-fields
(vec (concat [User :is_active :is_staff :google_auth] (models/default-fields User))))
(vec (concat [User :is_active :google_auth] (models/default-fields User))))
(defn bind-current-user
"Middleware that binds `metabase.api.common/*current-user*` and `*current-user-id*`
......
......@@ -21,7 +21,6 @@
(let [salt (str (java.util.UUID/randomUUID))
defaults {:date_joined (u/new-sql-timestamp)
:last_login nil
:is_staff true
:is_active true
:is_superuser false}]
;; always salt + encrypt the password before putting new User in the DB
......
......@@ -582,7 +582,6 @@
:executor_id executed-by
:json_query query
:query_hash query-hash
:query_id nil
:version 0
:status :starting
:error ""
......
......@@ -134,7 +134,6 @@
(expect-with-temp [Database [{database-id :id}]
Table [{table-id :id} {:db_id database-id}]]
{:description nil
:organization_id nil
:name card-name
:creator_id (user->id :rasta)
:dataset_query {:database database-id
......@@ -169,7 +168,6 @@
{:description nil
:can_read true
:can_write true
:organization_id nil
:dashboard_count 0
:name $
:creator_id (user->id :rasta)
......
......@@ -91,8 +91,7 @@
:parameters [{:hash "abc123", :name "test", :type "date"}]
:public_perms 0
:updated_at true
:created_at true
:organization_id nil}
:created_at true}
(-> ((user->client :rasta) :post 200 "dashboard" {:name "Test Create Dashboard"
:public_perms 0
:parameters [{:hash "abc123", :name "test", :type "date"}]})
......@@ -126,14 +125,12 @@
:public_perms 0
:creator_id (user->id :rasta)
:creator (user-details (fetch-user :rasta))
:organization_id nil
:display "table"
:query_type nil
:dataset_query {}
:visualization_settings {}
:archived false}
:series []}]
:organization_id nil}
:series []}]}
;; fetch a dashboard WITH a dashboard card on it
(tu/with-temp* [Dashboard [{dashboard-id :id} {:name "Test Dashboard"}]
Card [{card-id :id} {:name "Dashboard Test Card"}]
......@@ -152,7 +149,6 @@
:public_perms 0
:updated_at true
:created_at true
:organization_id nil
:parameters []}
{:name "My Cool Dashboard"
:description "Some awesome description"
......@@ -163,7 +159,6 @@
:public_perms 0
:updated_at true
:created_at true
:organization_id nil
:parameters []}
{:name "My Cool Dashboard"
:description "Some awesome description"
......@@ -174,7 +169,6 @@
:public_perms 0
:updated_at true
:created_at true
:organization_id nil
:parameters []}]
(tu/with-temp Dashboard [{dashboard-id :id} {:name "Test Dashboard"}]
(mapv dashboard-response [(Dashboard dashboard-id)
......
......@@ -57,7 +57,6 @@
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......@@ -89,7 +88,6 @@
:name $
:is_sample false
:is_full_sync false
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......@@ -167,7 +165,6 @@
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......@@ -180,7 +177,6 @@
:name $
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......@@ -201,7 +197,6 @@
:name $
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......@@ -218,7 +213,6 @@
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......@@ -240,7 +234,6 @@
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......
......@@ -23,7 +23,6 @@
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:features (mapv name (driver/features (driver/engine->driver :h2)))}))
......
......@@ -36,7 +36,6 @@
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:caveats nil
:points_of_interest nil
......
......@@ -127,7 +127,6 @@
:date_joined $
:last_login $
:is_active true
:is_staff true
:is_superuser false
:is_qbnewb true
:google_auth false
......
......@@ -31,7 +31,6 @@
{:description nil
:table_id (id :categories)
:database_id (id)
:organization_id nil
:query_type "query"
:name (:name card)
:creator_id (:creator_id card)
......
......@@ -212,9 +212,8 @@
`with-temp` should be preferrable going forward over creating random objects *without*
deleting them afterward.
(with-temp EmailReport [report {:creator_id (user->id :rasta)
:name (random-name)
:organization_id @org-id}]
(with-temp EmailReport [report {:creator_id (user->id :rasta)
:name (random-name)}]
...)"
[entity [binding-form & [options-map]] & body]
`(do-with-temp ~entity ~options-map (fn [~binding-form]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment