diff --git a/stores/migrations.go b/stores/migrations.go index ffb778be9..82fdaa449 100644 --- a/stores/migrations.go +++ b/stores/migrations.go @@ -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) @@ -303,7 +309,7 @@ func initSchema(tx *gorm.DB) error { // Change the collation of columns that we need to be case sensitive. if !isSQLite(tx) { - err = tx.Exec("ALTER TABLE objects MODIFY COLUMN object_id VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;").Error + err = tx.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) } @@ -311,7 +317,7 @@ func initSchema(tx *gorm.DB) error { if err != nil { return fmt.Errorf("failed to change buckets_name collation: %w", err) } - err = tx.Exec("ALTER TABLE multipart_uploads MODIFY COLUMN object_id VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;").Error + err = tx.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) } @@ -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 +}