Skip to main content

9A2.Upgrade 2.6.6.210

trydoforOriginalPracticeUpgradeAbout 5 min

9A2.Upgrade 2.6.6.210

Upgraded build 201 to 210 with the following major incompatibility,

  • java 11 instead of 8, compilation and startup parameters changed
  • boot 2.6 instead of 2.4, webmvc, path matching changed
  • shardingsphere 5.1 instead of 4.1, better structure
  • flywave __ instead of $ to be compatible with some Cloud DB
  • swagger springdoc instead of springfox to be compatible with boot2.6
  • fastjson2 instead of fastjson
  • check wings notable changelog

9A2.1.Modify pom.xml

Starting with 210, all artifactId are merged into pro.fessional.wings group. Here is how to modify parent and common dependencies.

<project>
<!-- change [wings-project] to [wings] -->
<parent>
    <!-- <groupId>pro.fessional</groupId> -->
    <!-- <artifactId>wings-project</artifactId> -->
    <groupId>pro.fessional</groupId>
    <artifactId>wings</artifactId>
    <version>2.6.6.210-SNAPSHOT</version>
</parent>
<!-- change [wings-] from artifactId to groupId [.wings] -->
<dependency>
  <!-- <groupId>pro.fessional</groupId> -->
  <!-- <artifactId>wings-silencer</artifactId> -->
  <groupId>pro.fessional.wings</groupId>
  <artifactId>silencer</artifactId>
  <version>${wings.version}</version>
</dependency>
</project>

9A2.2.Upgrade to java11

The current java11 used is openjdk build 11.0.2+9open in new window. It is recommended to manage the java8 and java11 environment with asdfopen in new window and set the JDK8_HOME and JDK11_HOME variables in the shell.

When IDEA or maven starts java program and TestCast, you need to add add-opens or add-exports parameters accordingly

  • maven-compiler-plugin - add-exports to compile
  • maven-surefire-plugin - add-opens to run
  • IDEA run TestCase - get surefire configuration automatically
  • IDEA run Java and Boot - manually set the startup parameter template

Where startup parameters are ${wings.java-opens} content, global variables like JAVA_TOOL_OPTIONS are not recommended. You need to set Application and Spring Boot in the Run/Debug Configuration Templates in IDEA.

References

9A2.3.Trace Table Naming

Mainly log table, changed from dollar to double underscore style, trigger suffix to prefix.

  • log table changed from table$log to table__
  • trigger from table$ai to ai__table

The operation steps are as follows.

  • Execute JournalManager.manageTriggers(table, true) to delete the old trigger
  • execute JournalManager.checkAndInitDdl(table, cid) to replace the old config with the new one
  • Rename journal table manually
  • Execute JournalManager.publishInsert/Update/Delete(table, true, cid) to generate a new trigger

If the data is mysql8 and meets to the wings specification, you can use the following sql test.

SELECT
  TABLE_NAME as TRACE_TBL,
  REPLACE(TABLE_NAME,'$log','') as PLAIN_TBL,
  CONCAT('ALTER TABLE ',table_name,' RENAME TO ', REPLACE(table_name, '$log','__'), ';;') as RENAME_DDL
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = DATABASE()
  AND table_name REGEXP '\\$log';

SELECT
  TRIGGER_NAME as OLD_NAME,
  REGEXP_REPLACE(TRIGGER_NAME,'^(.+)\\$(.+)$','$2__$1') as NEW_NAME,
  CONCAT('DROP TRIGGER IF EXISTS ',TRIGGER_NAME,';;') as DROP_DDL,
  REPLACE(CONCAT('CREATE TRIGGER `', REGEXP_REPLACE(TRIGGER_NAME,'^(.+)\\$(.+)$','$2__$1'), '` ',
    ACTION_TIMING, ' ', EVENT_MANIPULATION, ' ON `', EVENT_OBJECT_TABLE, '` FOR EACH ROW ',
    ACTION_STATEMENT, ';;'),'$log','__') as CREATE_DDL
FROM
  INFORMATION_SCHEMA.TRIGGERS
WHERE
  EVENT_OBJECT_SCHEMA = database();
--
DELIMITER ;;
-- Copy the above DROP_DDL, RENAME_DDL, CREATE_DDL and execute them in order.

9A2.4.Remove lombok's var

import lombok.var;

find . -type f -name '*.java' | while read -r fl; do
sed -i '' -E 's/import lombok.var;//g' $fl
done

9A2.5.Swagger3.0 Annotation

springdoc fully uses OpenApi/Swagger3.0, so springfox's Swagger2.0 annotations need to be replaced. See https://springdoc.org/#migrating-from-springfoxopen in new window for details

# check swagger2 annotation
find . -type f -name '*.java' | while read -r fl; do
grep 'import io.swagger.annotations' $fl >> /tmp/swagger.log
done
sort /tmp/swagger.log | uniq
rm -f /tmp/swagger.log

# Replace common tags and modify compilation errors caused by formatting deviations
find . -type f -name '*.java' | while read -r fl; do
sed -i '' -E 's/import io.swagger.annotations.ApiModel;/import io.swagger.v3.oas.annotations.media.Schema;/g' $fl
sed -i '' -E 's/import io.swagger.annotations.ApiModelProperty;/import io.swagger.v3.oas.annotations.media.Schema;/g' $fl
sed -i '' -E 's/import io.swagger.annotations.Api;/import io.swagger.v3.oas.annotations.tags.Tag;/g' $fl
sed -i '' -E 's/import io.swagger.annotations.ApiOperation;/import io.swagger.v3.oas.annotations.Operation;/g' $fl

sed -i '' -E 's/@ApiModel\((.*)\)/@Schema(description = \1)/g' $fl
sed -i '' -E 's/@ApiModelProperty\((.*)\)/@Schema(description = \1)/g' $fl
sed -i '' -E 's/@Api\((.*)\)/@Tag(name = \1)/g' $fl
sed -i '' -E 's/@ApiOperation\((.*)\)/@Operation(summary = \1)/g' $fl
done

9A2.6.Upgrade to Mysql8

Wings project use jooq, avoid complex sql, only sql basic features, generally no compatibility. Can use mysql shell to check,

# Option 1, need to install mysql shell
mysqlsh -- util checkForServerUpgrade root@wings-sql-dev5:3306 --target-version=8.0.26 --output-format=JSON
# Option 2, use mysql-client 8.0
mysqlcheck -u root -p --protocol=tcp -h kite-sql-dev5 --all-databases --check-upgrade

In-Place upgrade, that is, use the original data directory of 5.7, start mysql8 directly, and adjust its data structure automatically. Simple database (single machine, single container) is recommended, such as using docker to start mysql8.0, and check the following 2 items to upgrade automatically.

  • Its data points to mysql5.7's data.
  • Configure upgrade=FORCE in mysqld

Logical upgrade, meaning dump first and then restore, is recommended for complex databases (cloud, master-slave, cluster). When restoring directly from 5.7 FullDump to 8.0, you need to set the permission of upgrade=FORCE to full last upgrade. Otherwise, the user will be able to log in, but Access denied, so that the support users and features are not good.

Therefore, it is recommended to dump business users and datas separately on machines with mysql8 client, and then restore.

  • dump mysql5.7 business user, business data
  • restore mysql 8.0 user first then data
# Generate config file
cat >>kite-sql.cnf<< EOF
[client]
protocol=tcp
port=3306
user=trydofor
password=moilioncircle
EOF

# Use mysqlpump to support more options, all using mysql8's client
mysqlpump --defaults-extra-file=kite-sql.cnf -h kite-sql-dev5 \
--all-databases --exclude-databases=information_schema,mysql,performance_schema,sys \
--set-gtid-purged=OFF > mysql-5.7-data.sql

mysqlpump --defaults-extra-file=kite-sql.cnf -h kite-sql-dev5 \
--users --exclude-users=root,%backup \
--exclude-databases=% --set-gtid-purged=OFF > mysql-5.7-user.sql

echo "flush privileges;" >> mysql-5.7-user.sql

# If the dump is not ignoring innodb_*_status, you need to use --force to skip the error
cat mysql-5.7-user.sql mysql-5.7-data.sql \
| mysql --defaults-extra-file=kite-sql.cnf -h kite-sql-dev

9A2.7.Damaging Impact

  • wings-project is no longer dependent on devtools, and projects using it as a parent must add the dependency.
  • Changed the url permission config of warlock security from list to map, clarifying the override relationship from loose to strict.
  • Mirana rewrite DateLocaling method name, if compile error, you can rely on the parameter signature, bulk replacement method name.
  • Warlock1SchemaManager rename methods
  • Rename @JsonI18nString to @AutoI18nString

9A2.8.JooqDao Incompatible

The previous static reference is no longer recommended.

  • val t = dao.getTable()
  • val a = dao.getAlias()

It is recommended to define local variables with dao.getTable and getAlias instead of static global tables. The previous fetch(Condition) signature can be changed to the following form

  • fetch(Table, Condition)
  • fetch(t -> Fn.of(t.Id.eq(1L)))

9A2.9.External Api Compatibility

  • mysql8 does not have password function, use the following combination to replace it. SELECT CONCAT('*', UPPER(SHA1(UNHEX(SHA1('trydofor'))))), password('trydofor');

  • Adjustment of DateTimeFormatter in java11, such as Offset X's original XXX cannot represent XXXX and XXXXX, and so on.

  • fastjson2, you should simply replace com.alibaba.fastjson. with com.alibaba.fastjson2.. If the dependency on fastjson is too heavy and complex, please check the quality of the project and make sure the usage is safe.

9A2.A.Anthn Typo

Execute 2021-09-18v01 via Flywave to fix win_user_anthn typo error

a1.Execute Sql Script

If there is no shard table and no trace table, you can execute the upgrade sql manually. Otherwise, it is recommended to use flywave to execute it to avoid missing.

  • rename win_user_anthn
  • update sys_light_sequence
  • update shard table_#
  • update trace table$log
  • update triggers

a2.Replace Java File

Whole project java file, replace the following strings,

sed -i 's/user_anthn/user_authn/g'
sed -i 's/UserAnthn/UserAuthn/g'

9A2.B.Split WarlockBond

The default database implementation of user privileges, split into the warlock-bond project.

  • if not needed, dependency warlock
  • otherwise, dependency warlock-bond

Also add 2020-10-23v01 to remove flywave-fit warnings.

INSERT IGNORE INTO `sys_schema_version` 
(`revision`,`commit_id`,`apply_dt`,`comments`,`upto_sql`,`undo_sql`) 
VALUES (2020102302,-1,NOW(3),'','','');

9A2.C.Split CodeGen

code generation tools, split into separate projects, faceless-codegen and warlock-codegen, respectively. In practice, the direct dependency on warlock-codegen can be used, the sample maven configuration is as follows

<dependency>
    <groupId>pro.fessional.wings</groupId>
    <artifactId>warlock-codegen</artifactId>
    <scope>test</scope>
</dependency>

9A2.D.I18n Change

The semantics of ukey in sys_standard_i18n is to constrain unique data or enum class location members

  • id type - id. + id
  • code type - type + . + code
  • java enum, consists of package, class, member name

changes include, data records and generated code of I18n,

  • replace the data, such as 2019-05-21v01-enum-i18n.sql
  • regenerate the template code, such as StandardLanguage

9A2.E.Properties Change

e1.wings-monitor-79.properties

  • change report-keyword to notice-keyword