Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB schema: rename experiments unique index #579

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/api/mlflow/dao/models/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
// Experiment represents model to work with `experiments` table.
type Experiment struct {
ID *int32 `gorm:"column:experiment_id;not null;primaryKey"`
Name string `gorm:"type:varchar(256);not null;index:idx_namespace_name,unique"`
Name string `gorm:"type:varchar(256);not null;index:,unique,composite:name"`
ArtifactLocation string `gorm:"type:varchar(256)"`
LifecycleStage LifecycleStage `gorm:"type:varchar(32);check:lifecycle_stage IN ('active', 'deleted')"`
CreationTime sql.NullInt64 `gorm:"type:bigint"`
LastUpdateTime sql.NullInt64 `gorm:"type:bigint"`
NamespaceID uint `gorm:"index:idx_namespace_name,unique"`
NamespaceID uint `gorm:"index:,unique,composite:name"`
Namespace Namespace
Tags []ExperimentTag `gorm:"constraint:OnDelete:CASCADE"`
Runs []Run `gorm:"constraint:OnDelete:CASCADE"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/database/migrations/v_0006/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Migrate(db *gorm.DB) error {
if err := tx.Migrator().AlterColumn(&Experiment{}, "Name"); err != nil {
return err
}
if err := tx.Migrator().CreateIndex(&Experiment{}, "idx_namespace_name"); err != nil {
if err := tx.Migrator().CreateIndex(&Experiment{}, "Name"); err != nil {
return err
}
return tx.Model(&SchemaVersion{}).
Expand Down
4 changes: 2 additions & 2 deletions pkg/database/migrations/v_0006/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ type Namespace struct {

type Experiment struct {
ID *int32 `gorm:"column:experiment_id;not null;primaryKey"`
Name string `gorm:"type:varchar(256);not null;index:idx_namespace_name,unique"`
Name string `gorm:"type:varchar(256);not null;index:,unique,composite:name"`
ArtifactLocation string `gorm:"type:varchar(256)"`
LifecycleStage LifecycleStage `gorm:"type:varchar(32);check:lifecycle_stage IN ('active', 'deleted')"`
CreationTime sql.NullInt64 `gorm:"type:bigint"`
LastUpdateTime sql.NullInt64 `gorm:"type:bigint"`
NamespaceID uint `gorm:"index:idx_namespace_name,unique"`
NamespaceID uint `gorm:"index:,unique,composite:name"`
Namespace Namespace
Tags []ExperimentTag `gorm:"constraint:OnDelete:CASCADE"`
Runs []Run `gorm:"constraint:OnDelete:CASCADE"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/database/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ type Namespace struct {

type Experiment struct {
ID *int32 `gorm:"column:experiment_id;not null;primaryKey"`
Name string `gorm:"type:varchar(256);not null;index:idx_namespace_name,unique"`
Name string `gorm:"type:varchar(256);not null;index:,unique,composite:name"`
ArtifactLocation string `gorm:"type:varchar(256)"`
LifecycleStage LifecycleStage `gorm:"type:varchar(32);check:lifecycle_stage IN ('active', 'deleted')"`
CreationTime sql.NullInt64 `gorm:"type:bigint"`
LastUpdateTime sql.NullInt64 `gorm:"type:bigint"`
NamespaceID uint `gorm:"index:idx_namespace_name,unique"`
NamespaceID uint `gorm:"index:,unique,composite:name"`
Namespace Namespace
Tags []ExperimentTag `gorm:"constraint:OnDelete:CASCADE"`
Runs []Run `gorm:"constraint:OnDelete:CASCADE"`
Expand Down