-1

I backup a smallish sql database with a crontab, mysqldump, and checking it into source control. The minor database changes often result in unreadable diffs in source control log. That frustrates people in the "commit then review" pipeline.

The cause is extremely long lines that have minor changes hidden in them. For example here's an example based on a Wordpress database:

INSERT INTO `site_options` (`option_id`, `option_name`, `option_value`, `autoload`) VALUES (1, 'siteurl', 'http://example.org/', 'yes'),(2, 'home', 'http://example.org/', 'yes'),(3, 'blogname', 'Example', 'yes'),(4, 'blogdescription', 'Awesome Description', 'yes'),(5, 'users_can_register', '0', 'yes'),(6, 'admin_email', 'alice@example.org', 'yes'),(7, 'start_of_week', '1', 'yes'),(8, 'use_balanceTags', '0', 'yes'),(9, 'use_smilies', '1', 'yes'),(10, 'require_name_email', '', 'yes'),(11, 'comments_notify', '', 'yes'), (12, 'posts_per_rss', '10', 'yes'),(13, 'rss_use_excerpt', '0', 'yes'), ...

I've got inserts that go on for many thousands of characters/line could, presumably, be formatted with line breaks after each element/row.

Gazing at these I think: "Yeah, I bet if ran this thru a pretty printer of some kind the diff would be much more concise." A casual search didn't turn up a switch on mysqldump, or obvious choice for an open source sql pretty printer. And then I think "Gosh somebody must have addressed this already."

Suggestions?

Ben Hyde
  • 1,503
  • 12
  • 14

1 Answers1

0

This question is a duplicate of How to deal with enormous line lengths created by mysqldump where in we learn that it is impossible to fix this problem without patching mysqldump, or post processing with another tool. Which would need to comprehend sql syntax to get it right.

Community
  • 1
  • 1
Ben Hyde
  • 1,503
  • 12
  • 14