From ca13f50aa163be637bf1271159c07dceae3de0b9 Mon Sep 17 00:00:00 2001 From: Jasdeep Khalsa Date: Mon, 25 May 2015 13:14:50 +0100 Subject: [PATCH 1/6] Create gh-pages branch via GitHub --- index.html | 182 +++++++++++++++ params.json | 1 + stylesheets/github-light.css | 116 ++++++++++ stylesheets/normalize.css | 424 +++++++++++++++++++++++++++++++++++ stylesheets/stylesheet.css | 245 ++++++++++++++++++++ 5 files changed, 968 insertions(+) create mode 100644 index.html create mode 100644 params.json create mode 100644 stylesheets/github-light.css create mode 100644 stylesheets/normalize.css create mode 100644 stylesheets/stylesheet.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..b752ea2 --- /dev/null +++ b/index.html @@ -0,0 +1,182 @@ + + + + + DBDiff by DBDiff + + + + + + + + + +
+

+DBDiff CLI - Database Diff Command Line Interface

+ +

+The Problem

+ +

I've found a few solid​ ​migrat​ion tools like Flyway and Simple DB Migrate​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​

+ +

I found a diff tool by MySQL called mysqldbcompare, which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!

+ +

I must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.

+ +

​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:

+ +
    +
  1. Only do schema diffs
  2. +
  3. Are just too complex to get working or
  4. +
  5. Just don't produce valid SQL
  6. +
+ +

+The Solution

+ +

I think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.

+ +

This is what DBDiff is.

+ +

+Features of DBDiff

+ + + +

+Command-Line API

+ +
+Note: The command-line parameters will always override the settings in the .dbdiff config file
+ + + +

+Usage Examples

+ +

+Example 1

+ +

$ ./dbdiff server1.db1:server2.db2

+ +

This would by default look for the .dbdiff config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default

+ +

+Example 2

+ +

$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data

+ +

This would by default look for the .dbdiff config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default

+ +

+Example 3

+ +

$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql

+ +

Instead of looking for .dbdiff, this would look for config.conf (which should be valid YAML) for the settings, and then override any of those settings from config.conf for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool

+ +

+File Examples

+ +

+.dbdiff

+ +
    server1-user: user
+    server1-password: password
+    server1-port: port # for MySQL this is 3306
+    server1-host: host1 # usually localhost or 127.0.0.1
+    server2-user: user
+    server2-password: password
+    server2-port: port # for MySQL this is 3306
+    server2-host: host1 # usually localhost or 127.0.0.1
+    template: templates/simple-db-migrate.tmpl
+    type: all
+    include: all
+    no-comments: true
+
+ +

+simple-db-migrate.tmpl

+ +
    SQL_UP = u"""
+    {{ $up }}
+    """
+    SQL_DOWN = u"""
+    {{ $down }}
+    """
+
+ +

+How Does the Diff Actually Work?

+ +

The following comparisons run in exactly the following order:

+ + + +

+Overall Comparison

+ + + +

+Schema Comparison

+ + + +

+Data Comparison

+ + + + + +
+ + + + + diff --git a/params.json b/params.json new file mode 100644 index 0000000..ec5eeda --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- --server1=user:password@host1:port - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- --server2=user:password@host2:port - Specify the target db connection details (if it’s different to server1)\r\n- --template=templates/simple-db-migrate.tmpl - Specifies the output template, if any. By default will be plain SQL\r\n- --type=schema or data or all - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- --include=up or down or all - Specified whether to include the up, down or both data in the output. up is the default\r\n- --no-comments=true - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- --config=config.yaml - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- server1.db1.table1:server2.db2.table3 or server1.db1:server2.db2 - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- --output=./output-dir/today-up-schema.sql - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\t\tserver1-user: user\r\n\t\tserver1-password: password\r\n\t\tserver1-port: port # for MySQL this is 3306\r\n\t\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\t\tserver2-user: user\r\n\t\tserver2-password: password\r\n\t\tserver2-port: port # for MySQL this is 3306\r\n\t\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\t\ttemplate: templates/simple-db-migrate.tmpl\r\n\t\ttype: all\r\n\t\tinclude: all\r\n\t\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\t\tSQL_UP = u\"\"\"\r\n\t\t{{ $up }}\r\n\t\t\"\"\"\r\n\t\tSQL_DOWN = u\"\"\"\r\n\t\t{{ $down }}\r\n\t\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/stylesheets/github-light.css b/stylesheets/github-light.css new file mode 100644 index 0000000..872a6f4 --- /dev/null +++ b/stylesheets/github-light.css @@ -0,0 +1,116 @@ +/* + Copyright 2014 GitHub Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +.pl-c /* comment */ { + color: #969896; +} + +.pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */, +.pl-s .pl-v /* string variable */ { + color: #0086b3; +} + +.pl-e /* entity */, +.pl-en /* entity.name */ { + color: #795da3; +} + +.pl-s .pl-s1 /* string source */, +.pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ { + color: #333; +} + +.pl-ent /* entity.name.tag */ { + color: #63a35c; +} + +.pl-k /* keyword, storage, storage.type */ { + color: #a71d5d; +} + +.pl-pds /* punctuation.definition.string, string.regexp.character-class */, +.pl-s /* string */, +.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, +.pl-sr /* string.regexp */, +.pl-sr .pl-cce /* string.regexp constant.character.escape */, +.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */, +.pl-sr .pl-sre /* string.regexp source.ruby.embedded */ { + color: #183691; +} + +.pl-v /* variable */ { + color: #ed6a43; +} + +.pl-id /* invalid.deprecated */ { + color: #b52a1d; +} + +.pl-ii /* invalid.illegal */ { + background-color: #b52a1d; + color: #f8f8f8; +} + +.pl-sr .pl-cce /* string.regexp constant.character.escape */ { + color: #63a35c; + font-weight: bold; +} + +.pl-ml /* markup.list */ { + color: #693a17; +} + +.pl-mh /* markup.heading */, +.pl-mh .pl-en /* markup.heading entity.name */, +.pl-ms /* meta.separator */ { + color: #1d3e81; + font-weight: bold; +} + +.pl-mq /* markup.quote */ { + color: #008080; +} + +.pl-mi /* markup.italic */ { + color: #333; + font-style: italic; +} + +.pl-mb /* markup.bold */ { + color: #333; + font-weight: bold; +} + +.pl-md /* markup.deleted, meta.diff.header.from-file */ { + background-color: #ffecec; + color: #bd2c00; +} + +.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { + background-color: #eaffea; + color: #55a532; +} + +.pl-mdr /* meta.diff.range */ { + color: #795da3; + font-weight: bold; +} + +.pl-mo /* meta.output */ { + color: #1d3e81; +} + diff --git a/stylesheets/normalize.css b/stylesheets/normalize.css new file mode 100644 index 0000000..30366a6 --- /dev/null +++ b/stylesheets/normalize.css @@ -0,0 +1,424 @@ +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css new file mode 100644 index 0000000..b5f20c2 --- /dev/null +++ b/stylesheets/stylesheet.css @@ -0,0 +1,245 @@ +* { + box-sizing: border-box; } + +body { + padding: 0; + margin: 0; + font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.5; + color: #606c71; } + +a { + color: #1e6bb8; + text-decoration: none; } + a:hover { + text-decoration: underline; } + +.btn { + display: inline-block; + margin-bottom: 1rem; + color: rgba(255, 255, 255, 0.7); + background-color: rgba(255, 255, 255, 0.08); + border-color: rgba(255, 255, 255, 0.2); + border-style: solid; + border-width: 1px; + border-radius: 0.3rem; + transition: color 0.2s, background-color 0.2s, border-color 0.2s; } + .btn + .btn { + margin-left: 1rem; } + +.btn:hover { + color: rgba(255, 255, 255, 0.8); + text-decoration: none; + background-color: rgba(255, 255, 255, 0.2); + border-color: rgba(255, 255, 255, 0.3); } + +@media screen and (min-width: 64em) { + .btn { + padding: 0.75rem 1rem; } } + +@media screen and (min-width: 42em) and (max-width: 64em) { + .btn { + padding: 0.6rem 0.9rem; + font-size: 0.9rem; } } + +@media screen and (max-width: 42em) { + .btn { + display: block; + width: 100%; + padding: 0.75rem; + font-size: 0.9rem; } + .btn + .btn { + margin-top: 1rem; + margin-left: 0; } } + +.page-header { + color: #fff; + text-align: center; + background-color: #159957; + background-image: linear-gradient(120deg, #155799, #159957); } + +@media screen and (min-width: 64em) { + .page-header { + padding: 5rem 6rem; } } + +@media screen and (min-width: 42em) and (max-width: 64em) { + .page-header { + padding: 3rem 4rem; } } + +@media screen and (max-width: 42em) { + .page-header { + padding: 2rem 1rem; } } + +.project-name { + margin-top: 0; + margin-bottom: 0.1rem; } + +@media screen and (min-width: 64em) { + .project-name { + font-size: 3.25rem; } } + +@media screen and (min-width: 42em) and (max-width: 64em) { + .project-name { + font-size: 2.25rem; } } + +@media screen and (max-width: 42em) { + .project-name { + font-size: 1.75rem; } } + +.project-tagline { + margin-bottom: 2rem; + font-weight: normal; + opacity: 0.7; } + +@media screen and (min-width: 64em) { + .project-tagline { + font-size: 1.25rem; } } + +@media screen and (min-width: 42em) and (max-width: 64em) { + .project-tagline { + font-size: 1.15rem; } } + +@media screen and (max-width: 42em) { + .project-tagline { + font-size: 1rem; } } + +.main-content :first-child { + margin-top: 0; } +.main-content img { + max-width: 100%; } +.main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 { + margin-top: 2rem; + margin-bottom: 1rem; + font-weight: normal; + color: #159957; } +.main-content p { + margin-bottom: 1em; } +.main-content code { + padding: 2px 4px; + font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-size: 0.9rem; + color: #383e41; + background-color: #f3f6fa; + border-radius: 0.3rem; } +.main-content pre { + padding: 0.8rem; + margin-top: 0; + margin-bottom: 1rem; + font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace; + color: #567482; + word-wrap: normal; + background-color: #f3f6fa; + border: solid 1px #dce6f0; + border-radius: 0.3rem; } + .main-content pre > code { + padding: 0; + margin: 0; + font-size: 0.9rem; + color: #567482; + word-break: normal; + white-space: pre; + background: transparent; + border: 0; } +.main-content .highlight { + margin-bottom: 1rem; } + .main-content .highlight pre { + margin-bottom: 0; + word-break: normal; } +.main-content .highlight pre, .main-content pre { + padding: 0.8rem; + overflow: auto; + font-size: 0.9rem; + line-height: 1.45; + border-radius: 0.3rem; } +.main-content pre code, .main-content pre tt { + display: inline; + max-width: initial; + padding: 0; + margin: 0; + overflow: initial; + line-height: inherit; + word-wrap: normal; + background-color: transparent; + border: 0; } + .main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after { + content: normal; } +.main-content ul, .main-content ol { + margin-top: 0; } +.main-content blockquote { + padding: 0 1rem; + margin-left: 0; + color: #819198; + border-left: 0.3rem solid #dce6f0; } + .main-content blockquote > :first-child { + margin-top: 0; } + .main-content blockquote > :last-child { + margin-bottom: 0; } +.main-content table { + display: block; + width: 100%; + overflow: auto; + word-break: normal; + word-break: keep-all; } + .main-content table th { + font-weight: bold; } + .main-content table th, .main-content table td { + padding: 0.5rem 1rem; + border: 1px solid #e9ebec; } +.main-content dl { + padding: 0; } + .main-content dl dt { + padding: 0; + margin-top: 1rem; + font-size: 1rem; + font-weight: bold; } + .main-content dl dd { + padding: 0; + margin-bottom: 1rem; } +.main-content hr { + height: 2px; + padding: 0; + margin: 1rem 0; + background-color: #eff0f1; + border: 0; } + +@media screen and (min-width: 64em) { + .main-content { + max-width: 64rem; + padding: 2rem 6rem; + margin: 0 auto; + font-size: 1.1rem; } } + +@media screen and (min-width: 42em) and (max-width: 64em) { + .main-content { + padding: 2rem 4rem; + font-size: 1.1rem; } } + +@media screen and (max-width: 42em) { + .main-content { + padding: 2rem 1rem; + font-size: 1rem; } } + +.site-footer { + padding-top: 2rem; + margin-top: 2rem; + border-top: solid 1px #eff0f1; } + +.site-footer-owner { + display: block; + font-weight: bold; } + +.site-footer-credits { + color: #819198; } + +@media screen and (min-width: 64em) { + .site-footer { + font-size: 1rem; } } + +@media screen and (min-width: 42em) and (max-width: 64em) { + .site-footer { + font-size: 1rem; } } + +@media screen and (max-width: 42em) { + .site-footer { + font-size: 0.9rem; } } From eb19e1304e37ea213029e04d1560ae8944c5975e Mon Sep 17 00:00:00 2001 From: Jasdeep Khalsa Date: Tue, 26 May 2015 09:51:33 +0100 Subject: [PATCH 2/6] Create gh-pages branch via GitHub --- index.html | 54 ++++++++++++++++++++++++++--------------------------- params.json | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index b752ea2..a2bd6ef 100644 --- a/index.html +++ b/index.html @@ -68,15 +68,15 @@
Note: The command-line parameters will always override the settings in the .dbdiff config file

@@ -109,29 +109,29 @@

.dbdiff

-
    server1-user: user
-    server1-password: password
-    server1-port: port # for MySQL this is 3306
-    server1-host: host1 # usually localhost or 127.0.0.1
-    server2-user: user
-    server2-password: password
-    server2-port: port # for MySQL this is 3306
-    server2-host: host1 # usually localhost or 127.0.0.1
-    template: templates/simple-db-migrate.tmpl
-    type: all
-    include: all
-    no-comments: true
+
server1-user: user
+server1-password: password
+server1-port: port # for MySQL this is 3306
+server1-host: host1 # usually localhost or 127.0.0.1
+server2-user: user
+server2-password: password
+server2-port: port # for MySQL this is 3306
+server2-host: host1 # usually localhost or 127.0.0.1
+template: templates/simple-db-migrate.tmpl
+type: all
+include: all
+no-comments: true
 

simple-db-migrate.tmpl

-
    SQL_UP = u"""
-    {{ $up }}
-    """
-    SQL_DOWN = u"""
-    {{ $down }}
-    """
+
SQL_UP = u"""
+{{ $up }}
+"""
+SQL_DOWN = u"""
+{{ $down }}
+"""
 

diff --git a/params.json b/params.json index ec5eeda..a6f0076 100644 --- a/params.json +++ b/params.json @@ -1 +1 @@ -{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- --server1=user:password@host1:port - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- --server2=user:password@host2:port - Specify the target db connection details (if it’s different to server1)\r\n- --template=templates/simple-db-migrate.tmpl - Specifies the output template, if any. By default will be plain SQL\r\n- --type=schema or data or all - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- --include=up or down or all - Specified whether to include the up, down or both data in the output. up is the default\r\n- --no-comments=true - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- --config=config.yaml - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- server1.db1.table1:server2.db2.table3 or server1.db1:server2.db2 - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- --output=./output-dir/today-up-schema.sql - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\t\tserver1-user: user\r\n\t\tserver1-password: password\r\n\t\tserver1-port: port # for MySQL this is 3306\r\n\t\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\t\tserver2-user: user\r\n\t\tserver2-password: password\r\n\t\tserver2-port: port # for MySQL this is 3306\r\n\t\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\t\ttemplate: templates/simple-db-migrate.tmpl\r\n\t\ttype: all\r\n\t\tinclude: all\r\n\t\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\t\tSQL_UP = u\"\"\"\r\n\t\t{{ $up }}\r\n\t\t\"\"\"\r\n\t\tSQL_DOWN = u\"\"\"\r\n\t\t{{ $down }}\r\n\t\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--no-comments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file From 58e873a37f3006326253b21c4910555845ae68e6 Mon Sep 17 00:00:00 2001 From: Jasdeep Khalsa Date: Wed, 27 May 2015 16:58:04 +0100 Subject: [PATCH 3/6] Create gh-pages branch via GitHub --- index.html | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ params.json | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index a2bd6ef..080a5a3 100644 --- a/index.html +++ b/index.html @@ -61,6 +61,65 @@

  • Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)
  • +

    +Pre-requisites

    + +
      +
    1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (cmd)
    2. +
    3. You will need to have git installed: http://git-scm.com/downloads +
    4. +
    5. You will need to have PHP installed (version 5.4.x): http://php.net/manual/en/install.php +
    6. +
    7. You will need to have Composer installed which is a Dependency Manager for PHP: https://getcomposer.org +
    8. +
    + +

    Note: Make a note of where composer.phar is installed as we will need it later on during Setup

    + +

    +Installation

    + +

    On the command-line, use git to clone the ssh version:

    + +
    git clone git@github.com:DBDiff/DBDiff.git
    +
    + +

    Or use git to clone the https version:

    + +
    git clone https://github.com/DBDiff/DBDiff.git
    +
    + +

    Or download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:

    + +
    https://github.com/DBDiff/DBDiff/archive/master.zip
    +
    + +

    +Setup

    + +

    Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your "dbdiff" folder

    + +

    We are going to assume that composer.phar is installed inside your "dbdiff" folder. If it is installed elsewhere you will need to use it's exact path

    + +
      +
    1. Install the dependencies of the project with: php composer.phar install +
    2. +
    3. Make a .dbdiff file by following the [File Examples][] and place it in the root of your "dbdiff" directory
    4. +
    5. Type ./dbdiff {dbdiff command here e.g. server1.db1:server1.db2} to start the app! See [Command-Line API][] for more details on which commands you can run.
    6. +
    + +

    You should see something like...

    + +
    ℹ Now calculating schema diff for table `foo`
    +ℹ Now calculating data diff for table `foo`
    +ℹ Now generating UP migration
    +ℹ Now generating DOWN migration
    +ℹ Writing migration file to /path/to/dbdiff/migration.sql
    +✔ Completed
    +
    + +

    Congratulations you have installed and ran DBDiff!

    +

    Command-Line API

    diff --git a/params.json b/params.json index a6f0076..12e78e8 100644 --- a/params.json +++ b/params.json @@ -1 +1 @@ -{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--no-comments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Pre-requisites\r\n1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (`cmd`)\r\n2. You will need to have git installed: http://git-scm.com/downloads\r\n3. You will need to have PHP installed (version 5.4.x): http://php.net/manual/en/install.php\r\n4. You will need to have Composer installed which is a Dependency Manager for PHP: https://getcomposer.org\r\n\r\n_Note: Make a note of where `composer.phar` is installed as we will need it later on during Setup_\r\n\r\n# Installation\r\nOn the command-line, use `git` to clone the ssh version:\r\n\r\n git clone git@github.com:DBDiff/DBDiff.git\r\n\r\n**Or** use `git` to clone the https version:\r\n\r\n\tgit clone https://github.com/DBDiff/DBDiff.git\r\n\r\n**Or** download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:\r\n\r\n\thttps://github.com/DBDiff/DBDiff/archive/master.zip\r\n\r\n# Setup\r\n\r\n_Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your \"dbdiff\" folder_\r\n\r\n_We are going to assume that `composer.phar` is installed inside your \"dbdiff\" folder. If it is installed elsewhere you will need to use it's exact path_\r\n\r\n1. Install the dependencies of the project with: `php composer.phar install`\r\n2. Make a `.dbdiff` file by following the [File Examples][] and place it in the root of your \"dbdiff\" directory\r\n3. Type `./dbdiff {dbdiff command here e.g. server1.db1:server1.db2}` to start the app! See [Command-Line API][] for more details on which commands you can run.\r\n\r\nYou should see something like...\r\n\r\n\tℹ Now calculating schema diff for table `foo`\r\n\tℹ Now calculating data diff for table `foo`\r\n\tℹ Now generating UP migration\r\n\tℹ Now generating DOWN migration\r\n\tℹ Writing migration file to /path/to/dbdiff/migration.sql\r\n\t✔ Completed\r\n\r\nCongratulations you have installed and ran DBDiff!\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--no-comments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file From eaa979dc8f4e480675c9682df743cf7424d09e4c Mon Sep 17 00:00:00 2001 From: Jasdeep Khalsa Date: Wed, 27 May 2015 17:00:14 +0100 Subject: [PATCH 4/6] Create gh-pages branch via GitHub --- index.html | 4 ++-- params.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 080a5a3..8d13561 100644 --- a/index.html +++ b/index.html @@ -104,8 +104,8 @@

    1. Install the dependencies of the project with: php composer.phar install
    2. -
    3. Make a .dbdiff file by following the [File Examples][] and place it in the root of your "dbdiff" directory
    4. -
    5. Type ./dbdiff {dbdiff command here e.g. server1.db1:server1.db2} to start the app! See [Command-Line API][] for more details on which commands you can run.
    6. +
    7. Make a .dbdiff file by following the File Examples and place it in the root of your "dbdiff" directory
    8. +
    9. Type ./dbdiff {dbdiff command here e.g. server1.db1:server1.db2} to start the app! See Command-Line API for more details on which commands you can run.

    You should see something like...

    diff --git a/params.json b/params.json index 12e78e8..6969cf2 100644 --- a/params.json +++ b/params.json @@ -1 +1 @@ -{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Pre-requisites\r\n1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (`cmd`)\r\n2. You will need to have git installed: http://git-scm.com/downloads\r\n3. You will need to have PHP installed (version 5.4.x): http://php.net/manual/en/install.php\r\n4. You will need to have Composer installed which is a Dependency Manager for PHP: https://getcomposer.org\r\n\r\n_Note: Make a note of where `composer.phar` is installed as we will need it later on during Setup_\r\n\r\n# Installation\r\nOn the command-line, use `git` to clone the ssh version:\r\n\r\n git clone git@github.com:DBDiff/DBDiff.git\r\n\r\n**Or** use `git` to clone the https version:\r\n\r\n\tgit clone https://github.com/DBDiff/DBDiff.git\r\n\r\n**Or** download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:\r\n\r\n\thttps://github.com/DBDiff/DBDiff/archive/master.zip\r\n\r\n# Setup\r\n\r\n_Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your \"dbdiff\" folder_\r\n\r\n_We are going to assume that `composer.phar` is installed inside your \"dbdiff\" folder. If it is installed elsewhere you will need to use it's exact path_\r\n\r\n1. Install the dependencies of the project with: `php composer.phar install`\r\n2. Make a `.dbdiff` file by following the [File Examples][] and place it in the root of your \"dbdiff\" directory\r\n3. Type `./dbdiff {dbdiff command here e.g. server1.db1:server1.db2}` to start the app! See [Command-Line API][] for more details on which commands you can run.\r\n\r\nYou should see something like...\r\n\r\n\tℹ Now calculating schema diff for table `foo`\r\n\tℹ Now calculating data diff for table `foo`\r\n\tℹ Now generating UP migration\r\n\tℹ Now generating DOWN migration\r\n\tℹ Writing migration file to /path/to/dbdiff/migration.sql\r\n\t✔ Completed\r\n\r\nCongratulations you have installed and ran DBDiff!\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--no-comments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Pre-requisites\r\n1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (`cmd`)\r\n2. You will need to have git installed: http://git-scm.com/downloads\r\n3. You will need to have PHP installed (version 5.4.x): http://php.net/manual/en/install.php\r\n4. You will need to have Composer installed which is a Dependency Manager for PHP: https://getcomposer.org\r\n\r\n_Note: Make a note of where `composer.phar` is installed as we will need it later on during Setup_\r\n\r\n# Installation\r\nOn the command-line, use `git` to clone the ssh version:\r\n\r\n git clone git@github.com:DBDiff/DBDiff.git\r\n\r\n**Or** use `git` to clone the https version:\r\n\r\n\tgit clone https://github.com/DBDiff/DBDiff.git\r\n\r\n**Or** download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:\r\n\r\n\thttps://github.com/DBDiff/DBDiff/archive/master.zip\r\n\r\n# Setup\r\n\r\n_Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your \"dbdiff\" folder_\r\n\r\n_We are going to assume that `composer.phar` is installed inside your \"dbdiff\" folder. If it is installed elsewhere you will need to use it's exact path_\r\n\r\n1. Install the dependencies of the project with: `php composer.phar install`\r\n2. Make a `.dbdiff` file by following the [File Examples](#file-examples) and place it in the root of your \"dbdiff\" directory\r\n3. Type `./dbdiff {dbdiff command here e.g. server1.db1:server1.db2}` to start the app! See [Command-Line API](#command-line-api) for more details on which commands you can run.\r\n\r\nYou should see something like...\r\n\r\n\tℹ Now calculating schema diff for table `foo`\r\n\tℹ Now calculating data diff for table `foo`\r\n\tℹ Now generating UP migration\r\n\tℹ Now generating DOWN migration\r\n\tℹ Writing migration file to /path/to/dbdiff/migration.sql\r\n\t✔ Completed\r\n\r\nCongratulations you have installed and ran DBDiff!\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--no-comments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file From ee668d96b465550014ec1361edfbd62ed963d4be Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Fri, 12 Aug 2016 15:22:27 -0300 Subject: [PATCH 5/6] To disable comments the command is actually --nocomments=true --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 8d13561..7500546 100644 --- a/index.html +++ b/index.html @@ -132,8 +132,8 @@
  • --template=templates/simple-db-migrate.tmpl - Specifies the output template, if any. By default will be plain SQL
  • --type=schema or data or all - Specifies the type of diff to do either on the schema, data or both. schema is the default
  • --include=up or down or all - Specified whether to include the up, down or both data in the output. up is the default
  • -
  • --no-comments=true - By default automated comments starting with the hash (#) character are included in the output file, which can be removed with this parameter
  • -
  • --config=config.yaml - By default, DBDiff will look for a .dbdiff file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.
  • +
  • --nocomments=true - By default automated comments starting with the hash (#) character are included in the output file, which can be removed with this parameter
  • +
  • --config=config.yaml - By default, DBDiff will look for a .dbdiff file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, nocomments. Please note: a command-line parameter will always override any config file.
  • server1.db1.table1:server2.db2.table3 or server1.db1:server2.db2 - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database
  • --output=./output-dir/today-up-schema.sql - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory
  • @@ -151,7 +151,7 @@

    Example 2

    -

    $ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data

    +

    $ ./dbdiff server1.development.table1:server2.production.table1 --nocomments=true --type=data

    This would by default look for the .dbdiff config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default

    @@ -179,7 +179,7 @@

    template: templates/simple-db-migrate.tmpl type: all include: all -no-comments: true +nocomments: true

    From 4183cf8b0388c3a69c643e85f1a8af13f5d84f01 Mon Sep 17 00:00:00 2001 From: Jasdeep Khalsa Date: Thu, 25 Aug 2016 14:53:45 +0100 Subject: [PATCH 6/6] Create gh-pages branch via GitHub --- index.html | 63 +++++++++++++++++++++------------ params.json | 8 ++++- stylesheets/github-light.css | 68 ++++++++++++++++++++---------------- 3 files changed, 85 insertions(+), 54 deletions(-) diff --git a/index.html b/index.html index 7500546..eef530c 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ DBDiff by DBDiff - + @@ -20,10 +20,10 @@

    Compare MySQL databases & automatically create s

    -DBDiff CLI - Database Diff Command Line Interface

    +DBDiff CLI - Database Diff Command Line Interface

    -The Problem

    +The Problem

    I've found a few solid​ ​migrat​ion tools like Flyway and Simple DB Migrate​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​

    @@ -40,19 +40,20 @@

    -The Solution

    +The Solution

    I think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.

    This is what DBDiff is.

    -Features of DBDiff

    +Features of DBDiff
    • Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP
    • Connects to a source and target database to do the comparison diff, locally and remotely
    • Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source
    • +
    • Some tables and/or fields can be ignored in the comparison with a YAML collection in the config file (see File Examples below)
    • Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows
    • Since this diff tool is being used for migrations, it provides up and down SQL in the same file
    • Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: SQL_UP = u""" {{ $up }} """ SQL_DOWN = u""" {{ $down }} """ @@ -62,7 +63,7 @@

    -Pre-requisites

    +Pre-requisites
    1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (cmd)
    2. @@ -77,7 +78,7 @@

      Note: Make a note of where composer.phar is installed as we will need it later on during Setup

      -Installation

      +Installation

      On the command-line, use git to clone the ssh version:

      @@ -94,15 +95,20 @@

      https://github.com/DBDiff/DBDiff/archive/master.zip
       
      +

      Or use composer to include DBDiff as a project dependency

      + +
      php composer.phar require "dbdiff/dbdiff:@dev"
      +
      +

      -Setup

      +Setup

      Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your "dbdiff" folder

      We are going to assume that composer.phar is installed inside your "dbdiff" folder. If it is installed elsewhere you will need to use it's exact path

        -
      1. Install the dependencies of the project with: php composer.phar install +
      2. If you didn't install DBDiff with composer, install the dependencies of the project with: php composer.phar install
      3. Make a .dbdiff file by following the File Examples and place it in the root of your "dbdiff" directory
      4. Type ./dbdiff {dbdiff command here e.g. server1.db1:server1.db2} to start the app! See Command-Line API for more details on which commands you can run.
      5. @@ -121,10 +127,10 @@

        Congratulations you have installed and ran DBDiff!

        -Command-Line API

        +Command-Line API
        -Note: The command-line parameters will always override the settings in the .dbdiff config file
        +Note: The command-line parameters will always override the settings in the .dbdiff config file
        • --server1=user:password@host1:port - Specify the source db connection details. If there is only one server the --server1 flag can be omitted
        • @@ -139,34 +145,34 @@

        -Usage Examples

        +Usage Examples

        -Example 1

        +Example 1

        $ ./dbdiff server1.db1:server2.db2

        This would by default look for the .dbdiff config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default

        -Example 2

        +Example 2

        $ ./dbdiff server1.development.table1:server2.production.table1 --nocomments=true --type=data

        This would by default look for the .dbdiff config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default

        -Example 3

        +Example 3

        $ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql

        Instead of looking for .dbdiff, this would look for config.conf (which should be valid YAML) for the settings, and then override any of those settings from config.conf for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool

        -File Examples

        +File Examples

        -.dbdiff

        +.dbdiff
        server1-user: user
         server1-password: password
        @@ -180,10 +186,22 @@ 

        type: all include: all nocomments: true +tablesToIgnore: +- table1 +- table2 +- table3 +fieldsToIgnore: + table1: + - field1 + - field2 + - field3 + table4: + - field1 + - field4

        -simple-db-migrate.tmpl

        +simple-db-migrate.tmpl
        SQL_UP = u"""
         {{ $up }}
        @@ -194,7 +212,7 @@ 

        -How Does the Diff Actually Work?

        +How Does the Diff Actually Work?

        The following comparisons run in exactly the following order:

        @@ -204,7 +222,7 @@

        -Overall Comparison

        +Overall Comparison
        • Check both databases exist and are accessible, if not, throw an error
        • @@ -212,7 +230,7 @@

        -Schema Comparison

        +Schema Comparison
        • Looks to see if there are any differences in column numbers, name, type, collation or attributes
        • @@ -220,7 +238,7 @@

        -Data Comparison

        +Data Comparison
        • And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8_general_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test
        • @@ -238,4 +256,3 @@

          - diff --git a/params.json b/params.json index 6969cf2..239eb3d 100644 --- a/params.json +++ b/params.json @@ -1 +1,7 @@ -{"name":"DBDiff","tagline":"Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.","body":"# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Pre-requisites\r\n1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (`cmd`)\r\n2. You will need to have git installed: http://git-scm.com/downloads\r\n3. You will need to have PHP installed (version 5.4.x): http://php.net/manual/en/install.php\r\n4. You will need to have Composer installed which is a Dependency Manager for PHP: https://getcomposer.org\r\n\r\n_Note: Make a note of where `composer.phar` is installed as we will need it later on during Setup_\r\n\r\n# Installation\r\nOn the command-line, use `git` to clone the ssh version:\r\n\r\n git clone git@github.com:DBDiff/DBDiff.git\r\n\r\n**Or** use `git` to clone the https version:\r\n\r\n\tgit clone https://github.com/DBDiff/DBDiff.git\r\n\r\n**Or** download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:\r\n\r\n\thttps://github.com/DBDiff/DBDiff/archive/master.zip\r\n\r\n# Setup\r\n\r\n_Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your \"dbdiff\" folder_\r\n\r\n_We are going to assume that `composer.phar` is installed inside your \"dbdiff\" folder. If it is installed elsewhere you will need to use it's exact path_\r\n\r\n1. Install the dependencies of the project with: `php composer.phar install`\r\n2. Make a `.dbdiff` file by following the [File Examples](#file-examples) and place it in the root of your \"dbdiff\" directory\r\n3. Type `./dbdiff {dbdiff command here e.g. server1.db1:server1.db2}` to start the app! See [Command-Line API](#command-line-api) for more details on which commands you can run.\r\n\r\nYou should see something like...\r\n\r\n\tℹ Now calculating schema diff for table `foo`\r\n\tℹ Now calculating data diff for table `foo`\r\n\tℹ Now generating UP migration\r\n\tℹ Now generating DOWN migration\r\n\tℹ Writing migration file to /path/to/dbdiff/migration.sql\r\n\t✔ Completed\r\n\r\nCongratulations you have installed and ran DBDiff!\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--no-comments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, no-comments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --no-comments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tno-comments: true\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{ + "name": "DBDiff", + "tagline": "Compare MySQL databases & automatically create schema & data change scripts/migrations rapidly (up & down SQL supported) for database version control. Supports all migration tools.", + "body": "# DBDiff CLI - Database Diff Command Line Interface\r\n\r\n#The Problem\r\n\r\nI've found a few solid​ ​migrat​ion tools like [Flyway](https://github.com/flyway/flyway) and [Simple DB Migrate](https://github.com/guilhermechapiewski/simple-db-migrate)​, the latter being my preference for it's simplicity​ but the former having a lot more commits and contributors.​ However,​ these are just migrators and do not help produce the actual diff/migration to be versioned​, which I would not like to do manually if it can be automated.​\r\n\r\nI found a diff tool by MySQL called [mysqldbcompare](http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqldbcompare.html), which outputs SQL​ for (some) schema and data changes​ but it​ shockingly doesn't​ ​produce valid SQL!!!\r\n\r\nI must say though everything the mysqldbcompare tool offers is great, doing the diff by connecting directly to a source and target database (can be locally or on another server) and doing a series of tests/checks (all of which can be skipped if need be), then checking both the schema and the data - but we just need it to produce valid SQL output and I think it also had trouble in validating the schema fully.\r\n\r\n​​I actually looked through A LOT of ​different ​schema and data diff tools (took me a whole weekend) and they all either:\r\n\r\n1. Only do schema diffs\r\n2. Are just too complex to get working or\r\n3. Just don't produce valid SQL\r\n\r\n#The Solution\r\nI think a solid migration tool mixed with an automated schema and data diff tool would be a great contribution to the open source community.\r\n\r\nThis is what DBDiff is.\r\n\r\n#Features of DBDiff\r\n- Works on Windows, Linux & Mac command-line/Terminal because it has been developed in PHP\r\n- Connects to a source and target database to do the comparison diff, locally and remotely\r\n- Diffs can include changes to the schema and/or data, both in valid SQL to bring the target up-to-date with the source\r\n- Some tables and/or fields can be ignored in the comparison with a YAML collection in the config file (see File Examples below)\r\n- Diffs are SUPER fast and this tool has been tested with databases of multiple tables of millions of rows\r\n- Since this diff tool is being used for migrations, it provides up and down SQL in the same file\r\n- Works with existing migration tools like Flyway and Simple DB Migrate by specifying output template files/formats, for example, Simple DB Migrate may work with simple-db-migrate.tmpl which includes: `SQL_UP = u\"\"\" {{ $up }} \"\"\" SQL_DOWN = u\"\"\" {{ $down }} \"\"\"`\r\n- Is Unicode aware, can work with UTF8 data, which includes foreign characters/symbols\r\n- Works with just MySQL for now, but we will be expanding to other DBs in the future on request (please create an issue!)\r\n\r\n# Pre-requisites\r\n1. You will need to have access to the command-line, for Linux/Mac a Terminal or on Windows it will be a command prompt (`cmd`)\r\n2. You will need to have git installed: http://git-scm.com/downloads\r\n3. You will need to have PHP installed (version 5.4.x): http://php.net/manual/en/install.php\r\n4. You will need to have Composer installed which is a Dependency Manager for PHP: https://getcomposer.org\r\n\r\n_Note: Make a note of where `composer.phar` is installed as we will need it later on during Setup_\r\n\r\n# Installation\r\nOn the command-line, use `git` to clone the ssh version:\r\n\r\n git clone git@github.com:DBDiff/DBDiff.git\r\n\r\n**Or** use `git` to clone the https version:\r\n\r\n\tgit clone https://github.com/DBDiff/DBDiff.git\r\n\r\n**Or** download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:\r\n\r\n\thttps://github.com/DBDiff/DBDiff/archive/master.zip\r\n\r\n**Or** use `composer` to include `DBDiff` as a project dependency\r\n\r\n\tphp composer.phar require \"dbdiff/dbdiff:@dev\"\r\n\r\n# Setup\r\n\r\n_Make sure you are in the root of your application for all the following steps, using 'cd' to navigate on the command line to where you have placed your \"dbdiff\" folder_\r\n\r\n_We are going to assume that `composer.phar` is installed inside your \"dbdiff\" folder. If it is installed elsewhere you will need to use it's exact path_\r\n\r\n1. If you didn't install `DBDiff` with `composer`, install the dependencies of the project with: `php composer.phar install`\r\n2. Make a `.dbdiff` file by following the [File Examples](#file-examples) and place it in the root of your \"dbdiff\" directory\r\n3. Type `./dbdiff {dbdiff command here e.g. server1.db1:server1.db2}` to start the app! See [Command-Line API](#command-line-api) for more details on which commands you can run.\r\n\r\nYou should see something like...\r\n\r\n\tℹ Now calculating schema diff for table `foo`\r\n\tℹ Now calculating data diff for table `foo`\r\n\tℹ Now generating UP migration\r\n\tℹ Now generating DOWN migration\r\n\tℹ Writing migration file to /path/to/dbdiff/migration.sql\r\n\t✔ Completed\r\n\r\nCongratulations you have installed and ran DBDiff!\r\n\r\n# Command-Line API\r\n\r\n###### Note: The command-line parameters will always override the settings in the `.dbdiff` config file\r\n\r\n- **--server1=user:password@host1:port** - Specify the source db connection details. If there is only one server the --server1 flag can be omitted\r\n- **--server2=user:password@host2:port** - Specify the target db connection details (if it’s different to server1)\r\n- **--template=templates/simple-db-migrate.tmpl** - Specifies the output template, if any. By default will be plain SQL\r\n- **--type=schema** or **data** or **all** - Specifies the type of diff to do either on the schema, data or both. schema is the default\r\n- **--include=up** or **down** or **all** - Specified whether to include the up, down or both data in the output. up is the default\r\n- **--nocomments=true** - By default automated comments starting with the hash (\\#) character are included in the output file, which can be removed with this parameter\r\n- **--config=config.yaml** - By default, DBDiff will look for a `.dbdiff` file in the current directory which is valid YAML, which may also be overridden with a config file that lists the database host, user, port and password of the source and target DBs in YAML format (instead of using the command line for it), or any of the other settings e.g. the format, template, type, include, nocomments. Please note: a command-line parameter will always override any config file.\r\n- **server1.db1.table1:server2.db2.table3** or **server1.db1:server2.db2** - The penultimate parameter is what to compare. This tool can compare just one table or all tables (entire db) from the database\r\n- **--output=./output-dir/today-up-schema.sql** - The last parameter is an output file and/or directory to output the diff to, which by default will output to the same directory the command is run in if no directory is specified. If a directory is specified, it should exist, otherwise an error will be thrown. If this path is not specified, the default file name becomes migration.sql in the current directory\r\n\r\n# Usage Examples\r\n\r\n## Example 1\r\n`$ ./dbdiff server1.db1:server2.db2`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the schema and output a commented migration.sql file inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 2\r\n`$ ./dbdiff server1.development.table1:server2.production.table1 --nocomments=true --type=data`\r\n\r\nThis would by default look for the `.dbdiff` config file for the DB connection details, if it’s not there the tool would return an error. If it’s there, the connection details would be used to compare the SQL of only the data of the specified table1 inside each database and output a .sql file which has no comments inside the current directory which includes only the up SQL as per default\r\n\r\n## Example 3\r\n`$ ./dbdiff --config=config.conf --template=templates/simple-db-migrate.tmpl --include=all server1.db1:server2.db2 --output=./sql/simple-schema.sql`\r\n\r\nInstead of looking for `.dbdiff`, this would look for `config.conf` (which should be valid YAML) for the settings, and then override any of those settings from `config.conf` for the --template and --include parameters given in the command-line parameters - thus comparing the source with the target database and outputting an SQL file called simple-schema.sql to the ./sql folder, which should already exist otherwise the program will throw an error, and which includes only the schema as an up and down SQL diff in the simple-db-migrate format (as specified by the template). This example would work perfectly alongside the simple-db-migrate tool\r\n\r\n# File Examples\r\n\r\n## .dbdiff\r\n\r\n\tserver1-user: user\r\n\tserver1-password: password\r\n\tserver1-port: port # for MySQL this is 3306\r\n\tserver1-host: host1 # usually localhost or 127.0.0.1\r\n\tserver2-user: user\r\n\tserver2-password: password\r\n\tserver2-port: port # for MySQL this is 3306\r\n\tserver2-host: host1 # usually localhost or 127.0.0.1\r\n\ttemplate: templates/simple-db-migrate.tmpl\r\n\ttype: all\r\n\tinclude: all\r\n\tnocomments: true\r\n\ttablesToIgnore:\r\n - table1\r\n - table2\r\n - table3\r\n fieldsToIgnore:\r\n table1:\r\n - field1\r\n - field2\r\n - field3\r\n table4:\r\n - field1\r\n - field4\r\n\r\n\r\n## simple-db-migrate.tmpl\r\n\r\n\tSQL_UP = u\"\"\"\r\n\t{{ $up }}\r\n\t\"\"\"\r\n\tSQL_DOWN = u\"\"\"\r\n\t{{ $down }}\r\n\t\"\"\"\r\n\r\n# How Does the Diff Actually Work?\r\n\r\nThe following comparisons run in exactly the following order:\r\n\r\n- When comparing multiple tables: all comparisons should be run\r\n- When comparing just one table with another: only run the schema and data comparisons\r\n\r\n## Overall Comparison\r\n- Check both databases exist and are accessible, if not, throw an error\r\n- The database collation is then compared between the source and the target and any differences noted for the output\r\n\r\n## Schema Comparison\r\n- Looks to see if there are any differences in column numbers, name, type, collation or attributes\r\n- Any new columns in the source, which are not found in the target, are added\r\n\r\n## Data Comparison\r\n- And then for each table, the table storage type (e.g. MyISAM, CSV), the collation (e.g. utf8\\_general\\_ci), and number of rows are compared, in that order. If there are any differences they are noted before moving onto the next test\r\n- Next, both changed rows as well as missing rows from each table are recorded\r\n", + "google": "", + "note": "Don't delete this file! It's used internally to help with page regeneration." +} \ No newline at end of file diff --git a/stylesheets/github-light.css b/stylesheets/github-light.css index 872a6f4..0c6b24d 100644 --- a/stylesheets/github-light.css +++ b/stylesheets/github-light.css @@ -1,17 +1,25 @@ /* - Copyright 2014 GitHub Inc. +The MIT License (MIT) - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +Copyright (c) 2016 GitHub, Inc. - http://www.apache.org/licenses/LICENSE-2.0 +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. */ @@ -19,18 +27,18 @@ color: #969896; } -.pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */, +.pl-c1 /* constant, variable.other.constant, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header */, .pl-s .pl-v /* string variable */ { color: #0086b3; } -.pl-e /* entity */, +.pl-e /* entity */, .pl-en /* entity.name */ { color: #795da3; } -.pl-s .pl-s1 /* string source */, -.pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ { +.pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */, +.pl-s .pl-s1 /* string source */ { color: #333; } @@ -42,13 +50,13 @@ color: #a71d5d; } -.pl-pds /* punctuation.definition.string, string.regexp.character-class */, -.pl-s /* string */, +.pl-s /* string */, +.pl-pds /* punctuation.definition.string, string.regexp.character-class */, .pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, -.pl-sr /* string.regexp */, -.pl-sr .pl-cce /* string.regexp constant.character.escape */, -.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */, -.pl-sr .pl-sre /* string.regexp source.ruby.embedded */ { +.pl-sr /* string.regexp */, +.pl-sr .pl-cce /* string.regexp constant.character.escape */, +.pl-sr .pl-sre /* string.regexp source.ruby.embedded */, +.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ { color: #183691; } @@ -61,24 +69,24 @@ } .pl-ii /* invalid.illegal */ { - background-color: #b52a1d; color: #f8f8f8; + background-color: #b52a1d; } .pl-sr .pl-cce /* string.regexp constant.character.escape */ { - color: #63a35c; font-weight: bold; + color: #63a35c; } .pl-ml /* markup.list */ { color: #693a17; } -.pl-mh /* markup.heading */, +.pl-mh /* markup.heading */, .pl-mh .pl-en /* markup.heading entity.name */, -.pl-ms /* meta.separator */ { - color: #1d3e81; +.pl-ms /* meta.separator */ { font-weight: bold; + color: #1d3e81; } .pl-mq /* markup.quote */ { @@ -86,28 +94,28 @@ } .pl-mi /* markup.italic */ { - color: #333; font-style: italic; + color: #333; } .pl-mb /* markup.bold */ { - color: #333; font-weight: bold; + color: #333; } .pl-md /* markup.deleted, meta.diff.header.from-file */ { - background-color: #ffecec; color: #bd2c00; + background-color: #ffecec; } .pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { - background-color: #eaffea; color: #55a532; + background-color: #eaffea; } .pl-mdr /* meta.diff.range */ { - color: #795da3; font-weight: bold; + color: #795da3; } .pl-mo /* meta.output */ {