lmmt MySQL 迁移工具开源项目

我要开发同款
匿名用户2019年12月11日
60阅读
所属分类Java、数据库相关、数据库管理工具
授权协议MIT

作品详情

这是一个MySQL迁移工具。

支持模块TableViewFunctionProcedureTrigger使用方法

引入jar包:

<dependency><groupId>cn.codeforfun</groupId><artifactId>mysql-migrate</artifactId><version>1.0.0</version></dependency>

测试方法:

importcn.codeforfun.migrate.core.diff.DiffResult;importcn.codeforfun.migrate.core.entity.DatabaseInfo;importorg.junit.Test;importjava.sql.SQLException;importjava.util.List;privatestaticfinalIntegerFROM_PORT=3306;privatestaticfinalStringFROM_HOST="localhost";privatestaticfinalStringFROM_USERNAME="root";privatestaticfinalStringFROM_PASSWORD="root";privatestaticfinalStringFROM_TABLE="test_db";privatestaticfinalIntegerTO_PORT=3307;privatestaticfinalStringTO_HOST="localhost";privatestaticfinalStringTO_USERNAME="root";privatestaticfinalStringTO_PASSWORD="root";privatestaticfinalStringTO_TABLE="test_db";@Testpublicvoiddiff()throwsSQLException{DatabaseInfofrom=newDatabaseInfo(FROM_HOST,FROM_PORT,FROM_TABLE,FROM_USERNAME,FROM_PASSWORD);DatabaseInfoto=newDatabaseInfo(TO_HOST,TO_PORT,TO_TABLE,TO_USERNAME,TO_PASSWORD);Migratemigrate=newMigrate().from(from).to(to);DiffResultdiffResult=migrate.diff();List<String>sqlList=diffResult.getSqlList();for(Stringsql:sqlList){System.out.println(sql);}}@Testpublicvoidupdate()throwsSQLException{DatabaseInfofrom=newDatabaseInfo(FROM_HOST,FROM_PORT,FROM_TABLE,FROM_USERNAME,FROM_PASSWORD);DatabaseInfoto=newDatabaseInfo(TO_HOST,TO_PORT,TO_TABLE,TO_USERNAME,TO_PASSWORD);Migratemigrate=newMigrate().from(from).to(to);migrate.update();}源码地址

Gitee仓库

Github仓库

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论