Adds ml_model_version table and model
What does this MR do and why?
Adds ml_model_versions, with ActiveRecord entity Ml::ModelVersions. This representes a version of a Machine Learning model in the Model registry.
A ModelVersion has:
- has a
version
- a project
- belongs to a
model
, of class Ml::Model. The name and project must match. When the model is deleted so is the model version. - belongs to a
package
. The name, version and project must match. When the package is deleted package_id is nullified.
Database
Up:
❯ rails db:migrate RAILS_ENV=development
main: == [advisory_lock_connection] object_id: 223480, pg_backend_pid: 21328
main: == 20230707090835 CreateMlModelVersions: migrating ============================
main: -- create_table(:ml_model_versions)
main: -- quote_column_name(:version)
main: -> 0.0000s
main: -> 0.0177s
main: == 20230707090835 CreateMlModelVersions: migrated (0.1206s) ===================
main: == [advisory_lock_connection] object_id: 223480, pg_backend_pid: 21328
main: == [advisory_lock_connection] object_id: 223820, pg_backend_pid: 21330
main: == 20230707094002 AddFkOnMlModelVersionsToMlModels: migrating =================
main: -- transaction_open?()
main: -> 0.0001s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE ml_model_versions ADD CONSTRAINT fk_4e8b59e7a8 FOREIGN KEY (model_id) REFERENCES ml_models (id) ON DELETE CASCADE NOT VALID;")
main: -> 0.0008s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0003s
main: -- execute("ALTER TABLE ml_model_versions VALIDATE CONSTRAINT fk_4e8b59e7a8;")
main: -> 0.0018s
main: -- execute("RESET statement_timeout")
main: -> 0.0003s
main: == 20230707094002 AddFkOnMlModelVersionsToMlModels: migrated (0.0232s) ========
main: == [advisory_lock_connection] object_id: 223820, pg_backend_pid: 21330
main: == [advisory_lock_connection] object_id: 224120, pg_backend_pid: 21332
main: == 20230707094003 AddFkOnMlModelVersionsToPackages: migrating =================
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE ml_model_versions ADD CONSTRAINT fk_39f8aa0b8a FOREIGN KEY (package_id) REFERENCES packages_packages (id) ON DELETE SET NULL NOT VALID;")
main: -> 0.0018s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0002s
main: -- execute("ALTER TABLE ml_model_versions VALIDATE CONSTRAINT fk_39f8aa0b8a;")
main: -> 0.0032s
main: -- execute("RESET statement_timeout")
main: -> 0.0003s
main: == 20230707094003 AddFkOnMlModelVersionsToPackages: migrated (0.0214s) ========
main: == [advisory_lock_connection] object_id: 224120, pg_backend_pid: 21332
Down:
main: == [advisory_lock_connection] object_id: 223180, pg_backend_pid: 20410
main: == 20230707094003 AddFkOnMlModelVersionsToPackages: reverting =================
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:ml_model_versions, {:column=>:package_id, :on_delete=>:nullify})
main: -> 0.0031s
main: == 20230707094003 AddFkOnMlModelVersionsToPackages: reverted (0.1226s) ========
main: == 20230707094002 AddFkOnMlModelVersionsToMlModels: reverting =================
main: -- transaction_open?()
main: -> 0.0000s
main: -- remove_foreign_key(:ml_model_versions, {:column=>:model_id, :on_delete=>:cascade})
main: -> 0.0020s
main: == 20230707094002 AddFkOnMlModelVersionsToMlModels: reverted (0.0099s) ========
main: == 20230707090835 CreateMlModelVersions: reverting ============================
main: -- drop_table(:ml_model_versions)
main: -> 0.0028s
main: == 20230707090835 CreateMlModelVersions: reverted (0.0055s) ===================
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #410130 (closed)
Edited by Eduardo Bonet