This project is mainly used to compare two databases and generate corresponding changes to the sql statement. Currently only mysql database is supported.
下载 Installing
通过npm全局下载 (Install globally with npm)
npm install dbdiff2 -g
使用方法use
使用数据库描述字符串,-s指的是目前修改的库,-t指的是你将要修改的目的库。
Use the database description string, -s refers to the currently modified library, and -t refers to the destination library you are about to modify.
mysqldiff run -s mysql://username:password@host[:port]/name -t mysql://username:password@host[:port]/name
The js file and the database description string are equivalent. When your js file is not in the current execution directory, you need to configure -c to define the location of the js file.
The path to the database configuration file, specifying files that are not in the current process directory. This configuration is unified for source and target
-c --configPath <configPath>
输出文件路径,指定输出结果的路径
Output the path of the file, specifying the path of the output result
Whether to process the result, the default is processing. If not processed, return the result object of the comparison. True (default): processing, false: no processing
Whether to display some warn objects if processed, the default is display. No differentiation is done in the result. true (default): display, false: no display
-w --warn [warn]
选择处理策略,是否将同一表的操作聚合到一个�语句。true(默认):聚合,false:分散
Select a processing strategy to aggregate the operations of the same table into a single statement. True (default): aggregate, false: scattered
-m --merge [merge]
支持外部处理方式,使用自己的处理方式。个性化处理方式,可部分替换处理方式,可全部替换。
Support external processing methods and use your own processing methods. Personalized processing, partial replacement processing, can be replaced.
Support to ignore the comparison of some tables, the specific configuration, please create a .dbignore file in the execution directory, which uses the minimatch way to write the filter rules, the conditions will be filtered out and will not participate in the comparison.
-i --ignore
例子 example
源文件和目的文件返回对象 Source file and destination file return object
To handle the file format yourself, please refer to Reference. Some configurations can be selected from it, and the result will be merged with the original processing in the file.