这是一个MySQL迁移工具。
支持模块TableViewFuctioProcedureTrigger使用方法引入jar包:
<depedecy><groupId>c.codeforfu</groupId><artifactId>mysql-migrate</artifactId><versio>1.0.0</versio></depedecy>测试方法:
importc.codeforfu.migrate.core.diff.DiffResult;importc.codeforfu.migrate.core.etity.DatabaseIfo;importorg.juit.Test;importjava.sql.SQLExceptio;importjava.util.List;privatestaticfialItegerFROM_PORT=3306;privatestaticfialStrigFROM_HOST="localhost";privatestaticfialStrigFROM_USERNAME="root";privatestaticfialStrigFROM_PASSWORD="root";privatestaticfialStrigFROM_TABLE="test_db";privatestaticfialItegerTO_PORT=3307;privatestaticfialStrigTO_HOST="localhost";privatestaticfialStrigTO_USERNAME="root";privatestaticfialStrigTO_PASSWORD="root";privatestaticfialStrigTO_TABLE="test_db";@Testpublicvoiddiff()throwsSQLExceptio{DatabaseIfofrom=ewDatabaseIfo(FROM_HOST,FROM_PORT,FROM_TABLE,FROM_USERNAME,FROM_PASSWORD);DatabaseIfoto=ewDatabaseIfo(TO_HOST,TO_PORT,TO_TABLE,TO_USERNAME,TO_PASSWORD);Migratemigrate=ewMigrate().from(from).to(to);DiffResultdiffResult=migrate.diff();List<Strig>sqlList=diffResult.getSqlList();for(Strigsql:sqlList){System.out.pritl(sql);}}@Testpublicvoidupdate()throwsSQLExceptio{DatabaseIfofrom=ewDatabaseIfo(FROM_HOST,FROM_PORT,FROM_TABLE,FROM_USERNAME,FROM_PASSWORD);DatabaseIfoto=ewDatabaseIfo(TO_HOST,TO_PORT,TO_TABLE,TO_USERNAME,TO_PASSWORD);Migratemigrate=ewMigrate().from(from).to(to);migrate.update();}源码地址Gitee仓库
Github仓库










评论