Skip to content

Commit

Permalink
stores: add migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Nov 6, 2023
1 parent fd2fc7f commit 05a5507
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions stores/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ func performMigrations(db *gorm.DB, logger *zap.SugaredLogger) error {
return performMigration00021_multipartUploadsBucketCascade(tx, logger)
},
},
{
ID: "00022_extendObjectID",
Migrate: func(tx *gorm.DB) error {
return performMigration00022_extendObjectID(tx, logger)
},
},
}
// Create migrator.
m := gormigrate.New(db, gormigrate.DefaultOptions, migrations)
Expand Down Expand Up @@ -973,3 +979,19 @@ func performMigration00021_multipartUploadsBucketCascade(txn *gorm.DB, logger *z
logger.Info("migration 00021_multipoartUploadsBucketCascade complete")
return nil
}

func performMigration00022_extendObjectID(txn *gorm.DB, logger *zap.SugaredLogger) error {
logger.Info("performing migration 00022_extendObjectID")
if !isSQLite(txn) {
err := txn.Exec("ALTER TABLE objects MODIFY COLUMN object_id VARCHAR(766) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;").Error
if err != nil {
return fmt.Errorf("failed to change object_id collation: %w", err)
}
err = txn.Exec("ALTER TABLE multipart_uploads MODIFY COLUMN object_id VARCHAR(766) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;").Error
if err != nil {
return fmt.Errorf("failed to change object_id collation: %w", err)
}
}
logger.Info("migration 00022_extendObjectID complete")
return nil
}

0 comments on commit 05a5507

Please sign in to comment.