Skip to content

inceased outbox VARCHAR column length to 2048 #155

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

Merged
merged 1 commit into from
Sep 6, 2019
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
17 changes: 17 additions & 0 deletions gbus/tx/mysql/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func sagaStoreTableMigration(svcName string) *migrator.Migration {
func outboxMigrations(svcName string) *migrator.Migration {

tblName := tx.GrabbitTableNameTemplate(svcName, "outbox")

query := `CREATE TABLE IF NOT EXISTS ` + tblName + ` (
rec_id int NOT NULL AUTO_INCREMENT,
message_id varchar(50) NOT NULL UNIQUE,
Expand All @@ -58,6 +59,21 @@ func outboxMigrations(svcName string) *migrator.Migration {
return nil
},
}

}

func outboxChangeColumnLength(svcName string) *migrator.Migration {
tblName := tx.GrabbitTableNameTemplate(svcName, "outbox")
increaseLengthSQL := `ALTER TABLE ` + tblName + ` MODIFY message_type VARCHAR(2048) NOT NULL, MODIFY exchange VARCHAR(2048) NOT NULL, MODIFY routing_key VARCHAR(2048) NOT NULL`
return &migrator.Migration{
Name: "increase column length to 2048",
Func: func(tx *sql.Tx) error {
if _, err := tx.Exec(increaseLengthSQL); err != nil {
return err
}
return nil
},
}
}

func timoutTableMigration(svcName string) *migrator.Migration {
Expand Down Expand Up @@ -107,6 +123,7 @@ func EnsureSchema(db *sql.DB, svcName string) {
sagaStoreTableMigration(svcName),
timoutTableMigration(svcName),
legacyMigrationsTable(svcName),
outboxChangeColumnLength(svcName),
))
if err != nil {
panic(err)
Expand Down