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",
|
"%s Zipping file\n\r",
|
||||||
style.Success(icon.Info),
|
style.Success(icon.Info),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Strip definers from the Dumpfile
|
||||||
|
myDump.RemoveDefiners(filename)
|
||||||
|
|
||||||
filename, _ = dump.ZipFile(filename)
|
filename, _ = dump.ZipFile(filename)
|
||||||
timeElapsed := time.Since(start)
|
timeElapsed := time.Since(start)
|
||||||
fmt.Printf(
|
fmt.Printf(
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ func (c *Client) Dump() error {
|
|||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-schema.sql"))
|
|
||||||
|
|
||||||
fmt.Printf(
|
fmt.Printf(
|
||||||
"%s Done dumping schema %s from %s\n\r",
|
"%s Done dumping schema %s from %s\n\r",
|
||||||
@@ -158,7 +157,7 @@ func (c *Client) Dump() error {
|
|||||||
"--compact",
|
"--compact",
|
||||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-data.sql"),
|
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-data.sql"),
|
||||||
c.databaseName).Run()
|
c.databaseName).Run()
|
||||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-data.sql"))
|
|
||||||
fmt.Printf(
|
fmt.Printf(
|
||||||
"%s Done dumping data %s from %s\n\r",
|
"%s Done dumping data %s from %s\n\r",
|
||||||
style.Success(icon.Check),
|
style.Success(icon.Check),
|
||||||
@@ -186,7 +185,7 @@ func (c *Client) Dump() error {
|
|||||||
"--compact",
|
"--compact",
|
||||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-routines.sql"),
|
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-routines.sql"),
|
||||||
c.databaseName).Run()
|
c.databaseName).Run()
|
||||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-routines.sql"))
|
|
||||||
fmt.Printf(
|
fmt.Printf(
|
||||||
"%s Done dumping routines %s from %s\n\r",
|
"%s Done dumping routines %s from %s\n\r",
|
||||||
style.Success(icon.Check),
|
style.Success(icon.Check),
|
||||||
@@ -197,17 +196,9 @@ func (c *Client) Dump() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeDefiners(filename string) {
|
func (c *Client) RemoveDefiners(filename string) {
|
||||||
// Regex 1: .*(DEFINER=[a-zA-Z0-9\x60%@]+).* (Used by procedures/funcs)
|
expressions := make([]string, 1)
|
||||||
// Regex 2: .*(\/\*\!50003.*!50003+).* (Used by triggers)
|
expressions[0] = `s/DEFINER=[^ ]* / /g`
|
||||||
// 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`
|
|
||||||
|
|
||||||
if !strings.Contains(filename, "data") {
|
if !strings.Contains(filename, "data") {
|
||||||
for _, re := range expressions {
|
for _, re := range expressions {
|
||||||
|
|||||||
Reference in New Issue
Block a user