Skip to content

Commit f6d8b05

Browse files
author
Guy Baron
authored
inceased outbox VARCHAR column length to 2048 (#155)
1 parent 8c84da2 commit f6d8b05

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gbus/tx/mysql/migrations.go

+17
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func sagaStoreTableMigration(svcName string) *migrator.Migration {
3434
func outboxMigrations(svcName string) *migrator.Migration {
3535

3636
tblName := tx.GrabbitTableNameTemplate(svcName, "outbox")
37+
3738
query := `CREATE TABLE IF NOT EXISTS ` + tblName + ` (
3839
rec_id int NOT NULL AUTO_INCREMENT,
3940
message_id varchar(50) NOT NULL UNIQUE,
@@ -58,6 +59,21 @@ func outboxMigrations(svcName string) *migrator.Migration {
5859
return nil
5960
},
6061
}
62+
63+
}
64+
65+
func outboxChangeColumnLength(svcName string) *migrator.Migration {
66+
tblName := tx.GrabbitTableNameTemplate(svcName, "outbox")
67+
increaseLengthSQL := `ALTER TABLE ` + tblName + ` MODIFY message_type VARCHAR(2048) NOT NULL, MODIFY exchange VARCHAR(2048) NOT NULL, MODIFY routing_key VARCHAR(2048) NOT NULL`
68+
return &migrator.Migration{
69+
Name: "increase column length to 2048",
70+
Func: func(tx *sql.Tx) error {
71+
if _, err := tx.Exec(increaseLengthSQL); err != nil {
72+
return err
73+
}
74+
return nil
75+
},
76+
}
6177
}
6278

6379
func timoutTableMigration(svcName string) *migrator.Migration {
@@ -107,6 +123,7 @@ func EnsureSchema(db *sql.DB, svcName string) {
107123
sagaStoreTableMigration(svcName),
108124
timoutTableMigration(svcName),
109125
legacyMigrationsTable(svcName),
126+
outboxChangeColumnLength(svcName),
110127
))
111128
if err != nil {
112129
panic(err)

0 commit comments

Comments
 (0)