Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for custom DB dump filter functions #38

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

benjaminbojko
Copy link

Allows for a custom filter function to run string operations on the DB dump before importing it to each environment.

For example, this allows for custom fixes regarding MySQL warnings as discussed in #6, #37 and #34 by adding the following filter:

local: {
  'title': 'local',
  //...
  'filter': function(mysql_dump) {
    return mysql_dump.replace(/^Warning.*\n?/gm, ''); // filter MySQL warnings
  }
}

I've also used it to switch between wordpress themes when pushing/pulling from/to local:

local: {
  'title': 'local',
  //...
  'filter': function(mysql_dump) {
    return mysql_dump
      .replace(/^Warning.*\n?/gm, '') // filter MySQL warnings
      .replace(/'(current_theme)','My Production Theme'/g, '\'$1\',\'My Development Theme\'')
      .replace(/'(stylesheet|template)','my-production-theme-folder'/g, '\'$1\',\'my-dev-theme-folder\'');
  }
}
//...
staging: {
  'title': 'staging',
  //...
  'filter': function(mysql_dump) {
    return mysql_dump
      .replace(/^Warning.*\n?/gm, '') // filter MySQL warnings
      .replace(/'(current_theme)','My Development Theme'/g, '\'$1\',\'My Production Theme\'')
      .replace(/'(stylesheet|template)','my-dev-theme-folder'/g, '\'$1\',\'my-production-theme-folder\'');
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants