NUAAwqy opened a new pull request, #6915:
URL: https://github.com/apache/rocketmq-dashboard/pull/6915

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5994
   
   ### Brief Description
   
   `db/schema.sql` widened `rmq_instance_message.queried_by`, 
`rmq_instance_trace.queried_by` and `rmq_operation_audit.operator` to 
`VARCHAR(128)` (with the idempotent trailing `ALTER TABLE ... MODIFY` 
statements), but schema.sql only runs against a fresh MySQL data directory or 
the dev H2 profile. The `ApplicationRunner` schema-migration beans that upgrade 
existing deployments never widen these columns, so a volume initialised before 
the change keeps `VARCHAR(64)`. `AuthService` allows usernames up to 128 
characters, so such accounts can log in while their query-history and audit 
rows silently fail to store (strict MySQL) or get truncated (laxer servers), 
and every owner-scoped read then misses the rows.
   
   This adds `UsernameColumnWideningSchemaMigration` (persistence package): at 
startup it checks `DatabaseMetaData` for each of the three (table, column) 
pairs and issues `ALTER TABLE ... MODIFY <col> VARCHAR(128)` only when the 
column exists and is narrower than 128. It is idempotent, skips missing tables, 
and a server that refuses the DDL is logged at WARN instead of failing boot, 
matching the in-place upgrade behaviour of the existing runners.
   
   ### How Did You Test This Change?
   
   New unit test `UsernameColumnWideningSchemaMigrationTest` (pure H2 in MySQL 
mode, same style as `QueryHistorySchemaMigrationTest`) covers: widening three 
`VARCHAR(64)` columns to 128 with rows preserved across two runs; 
already-widened columns untouched; missing tables skipped; boot survives a 
server that rejects the ALTER.
   
   Maven is not available in my environment, so I compiled and ran the test 
with javac (JDK 17) against the exact versions spring-boot-dependencies 4.1.0 
manages (spring-boot 4.1.0, spring-core/spring-context 7.0.8, commons-logging 
1.3.5, lombok 1.18.46, slf4j-api 2.0.18, h2 2.4.240, assertj-core 3.27.7, 
junit-platform-console-standalone 6.0.3):
   
   ```
   javac -encoding UTF-8 -cp "lib/*" -d classes 
src/UsernameColumnWideningSchemaMigration.java 
src/UsernameColumnWideningSchemaMigrationTest.java
   java -jar lib/junit-platform-console-standalone-6.0.3.jar execute -cp 
"classes:lib/*" --select-class 
org.apache.rocketmq.studio.persistence.UsernameColumnWideningSchemaMigrationTest
   ```
   
   Result: 4 tests found, 4 successful, 0 failed.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix:`)
   - [x] Tests added or updated for non-trivial changes
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/` 
(no UI changes)
   - [ ] Architecture constraints stay green (no Maven in my environment; the 
repo has no ArchUnit rules in `server/src/test`, and the new class mirrors the 
existing `QueryHistorySchemaMigration` runner pattern)
   - [x] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (none: this makes the 
running schema match what schema.sql already documents)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to