fix: Now run definers cleanup once after combining files. ✨
All checks were successful
CI / build (push) Successful in 4m28s
All checks were successful
CI / build (push) Successful in 4m28s
Closes #7
This commit is contained in:
@@ -72,6 +72,10 @@ to quickly create a Cobra application.`,
|
||||
"%s Zipping file\n\r",
|
||||
style.Success(icon.Info),
|
||||
)
|
||||
|
||||
// Strip definers from the Dumpfile
|
||||
myDump.RemoveDefiners(filename)
|
||||
|
||||
filename, _ = dump.ZipFile(filename)
|
||||
timeElapsed := time.Since(start)
|
||||
fmt.Printf(
|
||||
|
||||
@@ -131,7 +131,6 @@ func (c *Client) Dump() error {
|
||||
)
|
||||
return err
|
||||
}
|
||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-schema.sql"))
|
||||
|
||||
fmt.Printf(
|
||||
"%s Done dumping schema %s from %s\n\r",
|
||||
@@ -158,7 +157,7 @@ func (c *Client) Dump() error {
|
||||
"--compact",
|
||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-data.sql"),
|
||||
c.databaseName).Run()
|
||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-data.sql"))
|
||||
|
||||
fmt.Printf(
|
||||
"%s Done dumping data %s from %s\n\r",
|
||||
style.Success(icon.Check),
|
||||
@@ -186,7 +185,7 @@ func (c *Client) Dump() error {
|
||||
"--compact",
|
||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-routines.sql"),
|
||||
c.databaseName).Run()
|
||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-routines.sql"))
|
||||
|
||||
fmt.Printf(
|
||||
"%s Done dumping routines %s from %s\n\r",
|
||||
style.Success(icon.Check),
|
||||
@@ -197,17 +196,9 @@ func (c *Client) Dump() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeDefiners(filename string) {
|
||||
// Regex 1: .*(DEFINER=[a-zA-Z0-9\x60%@]+).* (Used by procedures/funcs)
|
||||
// Regex 2: .*(\/\*\!50003.*!50003+).* (Used by triggers)
|
||||
// Regex 3: (\/\*\!50013.*DEFINER \*\/) (Used in schema)
|
||||
// Regex 4: ^(.TRIGGER).(\x60.*) (Fix the create triggers)
|
||||
|
||||
expressions := make([]string, 4)
|
||||
expressions[0] = `s/(^.*)(.DEFINER=[a-zA-Z0-9_\x60%@]+)(.*)/$1$3/g`
|
||||
expressions[1] = `s/(.*)(\/\*\!50003.*!50003+)(.*)/$1$3/g`
|
||||
expressions[2] = `s/(\/\*\!50013.*DEFINER \*\/)//g`
|
||||
expressions[3] = `s/(^.TRIGGER).(\x60.*)/CREATE$1 $2/g`
|
||||
func (c *Client) RemoveDefiners(filename string) {
|
||||
expressions := make([]string, 1)
|
||||
expressions[0] = `s/DEFINER=[^ ]* / /g`
|
||||
|
||||
if !strings.Contains(filename, "data") {
|
||||
for _, re := range expressions {
|
||||
|
||||
Reference in New Issue
Block a user