diff --git a/resources/migrations/042_remove_unused_tables.yaml b/resources/migrations/042_remove_unused_tables.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e4dd9e01e382bb1d8715215af990ed1508c4daef --- /dev/null +++ b/resources/migrations/042_remove_unused_tables.yaml @@ -0,0 +1,45 @@ +databaseChangeLog: + - changeSet: + id: 42 + author: camsaul + changes: + - dropForeignKeyConstraint: + baseTableName: query_queryexecution + constraintName: fk_queryexecution_ref_query_id + - 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 diff --git a/src/metabase/db/migrations.clj b/src/metabase/db/migrations.clj index 20af0ab32a08fb63280abca108150ef7718d6fc4..a5349cc9d39bd67e8a34934dd21d940b94f8f5ab 100644 --- a/src/metabase/db/migrations.clj +++ b/src/metabase/db/migrations.clj @@ -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 diff --git a/src/metabase/middleware.clj b/src/metabase/middleware.clj index 05f75d429c7e4d4bdc1b86d14508acd75df90696..d3ff93e9aa815002901440093bb9c7be375a2022 100644 --- a/src/metabase/middleware.clj +++ b/src/metabase/middleware.clj @@ -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*` diff --git a/src/metabase/models/user.clj b/src/metabase/models/user.clj index 631bad260348dcd40aac017db266e82636176b14..16a644e9a77a9539a1a1ba2d1411dea46cc0ed67 100644 --- a/src/metabase/models/user.clj +++ b/src/metabase/models/user.clj @@ -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 diff --git a/src/metabase/query_processor.clj b/src/metabase/query_processor.clj index dde25c9d601f3ca90c83f5d1ab7589e71539890b..7876f0b1cfd9a5877b3bad60ed5b78a090014476 100644 --- a/src/metabase/query_processor.clj +++ b/src/metabase/query_processor.clj @@ -582,7 +582,6 @@ :executor_id executed-by :json_query query :query_hash query-hash - :query_id nil :version 0 :status :starting :error "" diff --git a/test/metabase/api/card_test.clj b/test/metabase/api/card_test.clj index 04dae7e586af896ebb00492fb421b04d11ca7ae5..2697549e175fa2e25a9837863e4da0d5c4473cb7 100644 --- a/test/metabase/api/card_test.clj +++ b/test/metabase/api/card_test.clj @@ -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) diff --git a/test/metabase/api/dashboard_test.clj b/test/metabase/api/dashboard_test.clj index 0baba4032ce108b10cd3f1e8ad9d7c918ff4b568..021461f83882e1dd6fa9980fc64f477316e97853 100644 --- a/test/metabase/api/dashboard_test.clj +++ b/test/metabase/api/dashboard_test.clj @@ -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) diff --git a/test/metabase/api/database_test.clj b/test/metabase/api/database_test.clj index e96e7e68855dd17b0f03199fc7974a83fc4c04ee..e3fe898b1964ed3c38042020e13231e83d8021ab 100644 --- a/test/metabase/api/database_test.clj +++ b/test/metabase/api/database_test.clj @@ -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 diff --git a/test/metabase/api/field_test.clj b/test/metabase/api/field_test.clj index 5e40a253524f1688c4b627282b8f019452b20b0c..8b836dd2c5a71415eb6aa2a6c265f0f780336b05 100644 --- a/test/metabase/api/field_test.clj +++ b/test/metabase/api/field_test.clj @@ -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)))})) diff --git a/test/metabase/api/table_test.clj b/test/metabase/api/table_test.clj index b48846b8fcc9fa7388a276075dfe4d7e179343d4..3c89254df581d47e836ae7b4dbf8f43f72c6128e 100644 --- a/test/metabase/api/table_test.clj +++ b/test/metabase/api/table_test.clj @@ -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 diff --git a/test/metabase/api/user_test.clj b/test/metabase/api/user_test.clj index 2ab8f1272cc170b2fc6a0f0d2b16716e327c4cdc..1ae1f1b75a0171ddc3a6a93028e92c5190207ec5 100644 --- a/test/metabase/api/user_test.clj +++ b/test/metabase/api/user_test.clj @@ -127,7 +127,6 @@ :date_joined $ :last_login $ :is_active true - :is_staff true :is_superuser false :is_qbnewb true :google_auth false diff --git a/test/metabase/events/revision_test.clj b/test/metabase/events/revision_test.clj index a2072fcda5ea3e4a70e182246e046f8b6102d4c5..7094acc25917413119181878ac07e9cb353359a7 100644 --- a/test/metabase/events/revision_test.clj +++ b/test/metabase/events/revision_test.clj @@ -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) diff --git a/test/metabase/test/util.clj b/test/metabase/test/util.clj index 1ea0dd0d028f81846ac3cd0fa3e08782ff6d46a8..4ef90a0400172d85ac7dd126f6cfc737fb6ffaa1 100644 --- a/test/metabase/test/util.clj +++ b/test/metabase/test/util.clj @@ -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]