{"id":16305258,"url":"https://github.com/moznion/java-mysql-diff","last_synced_at":"2025-03-20T21:31:34.153Z","repository":{"id":24887817,"uuid":"28303941","full_name":"moznion/java-mysql-diff","owner":"moznion","description":"Detect and extract diff between two table declarations from schema of MySQL","archived":false,"fork":false,"pushed_at":"2020-10-13T05:18:11.000Z","size":78,"stargazers_count":41,"open_issues_count":0,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-18T00:02:03.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moznion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-21T15:35:03.000Z","updated_at":"2024-07-09T11:16:08.000Z","dependencies_parsed_at":"2022-08-23T03:50:26.250Z","dependency_job_id":null,"html_url":"https://github.com/moznion/java-mysql-diff","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjava-mysql-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjava-mysql-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjava-mysql-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjava-mysql-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moznion","download_url":"https://codeload.github.com/moznion/java-mysql-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221809010,"owners_count":16883833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T21:06:10.227Z","updated_at":"2024-10-28T08:43:37.083Z","avatar_url":"https://github.com/moznion.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"mysql-diff [![Build Status](https://travis-ci.org/moznion/java-mysql-diff.svg?branch=master)](https://travis-ci.org/moznion/java-mysql-diff) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.moznion/mysql-diff/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.moznion/mysql-diff) [![javadoc.io](https://javadocio-badges.herokuapp.com/net.moznion/mysql-diff/badge.svg)](https://javadocio-badges.herokuapp.com/net.moznion/mysql-diff)\n==\n\nDetect and extract diff between two table declarations from schema of MySQL.\n\nSynopsis\n--\n\n### Use as CLI application\n\nExecutable fat-jar is available at [here](https://github.com/moznion/java-mysql-diff/releases).\n\n```\n$ java -jar [old_database] [new_database]\n```\n\nIf you want more details, please run this command with `--help` option.\n\n### Programmatically\n\n```java\nimport net.moznion.mysql.diff.DiffExtractor;\nimport net.moznion.mysql.diff.MySqlConnectionInfo;\nimport net.moznion.mysql.diff.SchemaDumper;\nimport net.moznion.mysql.diff.SchemaParser;\n\nMySqlConnectionInfo localMySqlConnectionInfo = MySqlConnectionInfo.builder()\n    // .host(\"your-host\")     // \"localhost\" is the default value\n    // .user(\"your-name\")     // \"root\" is the default value\n    // .pass(\"your-password\") // \"\" is the default value\n    // .url(\"jdbc:mysql://your-host:3306?cacheServerConfiguration=true\") // or you can specify host, port and properties by a URL\n    .build();\nSchemaDumper schemaDumper = new SchemaDumper(localMySqlConnectionInfo);\n\nfinal String oldSql = \"CREATE TABLE `sample` (\\n\"\n    + \"  `id` INTEGER(10) NOT NULL AUTO_INCREMENT,\\n\"\n    + \"  PRIMARY KEY (`id`)\\n\"\n    + \") ENGINE=InnoDB DEFAULT CHARSET=utf8;\\n\";\nfinal String newSql = \"CREATE TABLE `sample` (\\n\"\n    + \"  `id` INTEGER(10) NOT NULL AUTO_INCREMENT,\\n\"\n    + \"  `name` VARCHAR(32) NOT NULL,\\n\"\n    + \"  PRIMARY KEY (`id`)\\n\"\n    + \") ENGINE=InnoDB DEFAULT CHARSET=utf8;\\n\";\n\nString oldSchema = schemaDumper.dump(oldSql);\nString newSchema = schemaDumper.dump(newSql);\n\nList\u003cTable\u003e oldTables = SchemaParser.parse(oldSchema);\nList\u003cTable\u003e newTables = SchemaParser.parse(newSchema);\n\nString diff = DiffExtractor.extractDiff(oldTables, newTables);\n```\n\nDescription\n--\n\nThis package provides a function to detect and extract diff between two table declarations from schema.\n\nExtraction processing flow is following;\n\n1. Dump normalized schema by creating new database according to input and dump it out by using `mysqldump`\n2. Parse normalized schema\n3. Take diff between parsed structure\n\nThis package is port of onishi-san's [mysqldiff](https://github.com/onishi/mysqldiff) from Perl to Java.\n\nDependencies\n--\n\n- Java 8 or later\n- MySQL 5 or later (`mysqld` must be upped when this program is executed)\n- mysqldump\n\nHow to build fat-jar\n--\n\nIf you want to build an executable standalone jar,\nplease run following command;\n\n```\n$ mvn -P fatjar clean package\n```\n\nAnd now, generated runnable fat-jar file has been available on [GitHub Releases](https://github.com/moznion/java-mysql-diff/releases).\n\nSee Also\n--\n\n- [mysqldiff](https://github.com/onishi/mysqldiff)\n\nAuthor\n--\n\nmoznion (\u003cmoznion@gmail.com\u003e)\n\nLicense\n--\n\n```\nThe MIT License (MIT)\nCopyright © 2014 moznion, http://moznion.net/ \u003cmoznion@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Fjava-mysql-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoznion%2Fjava-mysql-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Fjava-mysql-diff/lists"}