-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
align migrations table name with grabbit convention (#140)
- Loading branch information
Guy Baron
authored
Aug 25, 2019
1 parent
58b7cec
commit a916269
Showing
5 changed files
with
62 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package tx | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
//SanitizeTableName returns a sanitizes and lower cased string for creating a table | ||
func SanitizeTableName(dirty string) string { | ||
|
||
var re = regexp.MustCompile(`-|;|\\|`) | ||
sanitized := re.ReplaceAllString(dirty, "") | ||
return strings.ToLower(sanitized) | ||
} | ||
|
||
//GrabbitTableNameTemplate returns the tamplated grabbit table name for the table type and service | ||
func GrabbitTableNameTemplate(svcName, table string) string { | ||
sanitized := SanitizeTableName(svcName) | ||
templated := fmt.Sprintf("grabbit_%s_%s", sanitized, table) | ||
return strings.ToLower(templated) | ||
|
||
} |