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

Extend object id max length #718

Merged
merged 4 commits into from
Nov 7, 2023
Merged
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
26 changes: 24 additions & 2 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)
},
},
{
ChrisSchinnerl marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -303,15 +309,15 @@ 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)
}
err = tx.Exec("ALTER TABLE buckets MODIFY COLUMN name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;").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)
}
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
}