DEV Community

Perlat Kociaj
Perlat Kociaj

Posted on • Updated on

WordPress Database replacing the easy way

Hi,
I published an NPM package a small cli tool which does the exporting and replacing the URL for a WordPress website piece of cake. You can export and replace within 10 seconds (depending on the size of the database and how fast you type).

demo

TLDR;
NPM link
Github link


I started this as a project for personal use but decided to make it as an NPM package and publicly accessible. We all know the ritual for WordPress development.

  • Develop local using Docker containers
  • Use git commit, git push (or FTP upload for old school hardcore people) to deploy
  • open phpmyadmin, find the database, export the database
  • find the file in the downloads folder (find which one is the latest from database (2).sql or database (3).sql or database (5).sql because you deleted (4)
  • replace the local URL with the staging/production URL you can do it by:
    • using any text editor to search/replace the URL or
    • using a plugin to import and replace URL in the database
      • Install the plugin
      • Configure the plugin
      • Run the search/replace and wait to finish
      • Done Or do the following while you are in your project directory:
  • run devild db:export and follow the instructions to export your database in your current directory
  • run devild db:replace and follow the instructions to replace the URL and create another file to keep the original one.
  • done ( ~10 seconds ā³ )

This package is available at NPM Registry where you can install it by running yarn global add @perlatsp/devild or npm i -g @perlatsp/devild

Feedback and PR are more than welcome. :D

šŸ˜ˆDevild - Wordpress DB export & replace the easy way

Database export and search replace for sql files

How to use

  • npm i -g @perlatsp/devild to install it as a global package.
  • You can now access it by running devild <command>
  • NOTE! If you are using devilbox / docker containers you will need to do the above inside the container.

Available commands

  • devild or devild help - Will display help message with available commands
  • devild db:export - Will ask credentials to export database
  • devild db:replace - Will ask questions to replace url in the exported sql file
  • devild install - Will create sample config file to create projects repositories (name,type,url)-
  • devild project:start - Will ask questions to create a new project based upon set configurations
  • devild project:add - Will ask questions to add a new project to your configuration file

TODO

  • Search Replace in current dir
  • Create Project (WPā€¦

Top comments (0)