fix: Invalid syntax on CREATE Trigger fixed.
All checks were successful
CI / build (push) Successful in 4m17s
All checks were successful
CI / build (push) Successful in 4m17s
Additional regex deployed to complete the transformation.
This commit is contained in:
@@ -120,6 +120,7 @@ func (c *Client) Dump() error {
|
||||
"--no-create-db",
|
||||
"--no-data",
|
||||
"--skip-triggers",
|
||||
"--compact",
|
||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-schema.sql"),
|
||||
c.databaseName).CombinedOutput()
|
||||
if err != nil {
|
||||
@@ -154,6 +155,7 @@ func (c *Client) Dump() error {
|
||||
"--no-create-db",
|
||||
"--no-create-info",
|
||||
"--skip-triggers",
|
||||
"--compact",
|
||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-data.sql"),
|
||||
c.databaseName).Run()
|
||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-data.sql"))
|
||||
@@ -181,6 +183,7 @@ func (c *Client) Dump() error {
|
||||
"--no-data",
|
||||
"--triggers",
|
||||
"--routines",
|
||||
"--compact",
|
||||
"--result-file", filepath.Join(c.storagePath, c.databaseName+"-routines.sql"),
|
||||
c.databaseName).Run()
|
||||
removeDefiners(filepath.Join(c.storagePath, c.databaseName+"-routines.sql"))
|
||||
@@ -198,11 +201,13 @@ 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, 3)
|
||||
expressions[0] = `s/(^.*)(.DEFINER=[a-zA-Z0-9_\x60%@]+)(.*)/$1$3/gm`
|
||||
expressions[1] = `s/(.*)(\/\*\!50003.*!50003+)(.*)/$1$3/gm`
|
||||
expressions[2] = `s/(\/\*\!50013.*DEFINER \*\/)//gm`
|
||||
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") {
|
||||
for _, re := range expressions {
|
||||
|
||||
Reference in New Issue
Block a user