Fix db_ddl.sql: align with authoritative openas2-schema.xml#538
Merged
uhurusurfa merged 1 commit intoJun 15, 2026
Merged
Conversation
The DDL Utils schema at Server/src/resources/db/openas2-schema.xml has
been the source of truth for the msg_metadata table since the schema was
introduced, but the SQL script in Server/src/config/db_ddl.sql has not
been kept in sync. The most impactful gap is a missing SENT_FILE_NAME
column, which DbTrackingModule writes to but is absent from the table
created via this DDL — breaking any deployment that bootstraps the H2
schema with this file instead of the ant-based create_db_table.sh route.
This commit aligns db_ddl.sql with openas2-schema.xml:
* Adds SENT_FILE_NAME VARCHAR(255) immediately after FILE_NAME (matches
the position in the XML and the order used by DbTrackingModule inserts).
* Promotes MSG_ID, PRIOR_MSG_ID, MDN_ID, MDN_RESPONSE and STATE_MSG from
unbounded VARCHAR to LONGVARCHAR, mirroring the XML.
* Applies the column defaults declared in the XML:
- IS_RESEND DEFAULT 'N'
- RESEND_COUNT DEFAULT 0
- CREATE_DT DEFAULT CURRENT_TIMESTAMP
* Adds an explicit reminder comment so the two files do not drift again.
The same fix is mirrored in Server/src/test/resources/config/db_ddl.sql
to keep the test fixture aligned.
This was field-validated in two independent deployments running OpenAS2
v4.8.2 on Debian 13 + OpenJDK 21 with embedded H2 and
tcp_server_start="false" (where create_db_table.sh is not usable
because it relies on ant + a TCP 9092 listener that the deployments
intentionally do not enable).
uhurusurfa
approved these changes
Jun 15, 2026
uhurusurfa
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fixes.
The next release for OpenAS2 will be a major release using Hibernate to manage the schema so the use of DDL utils and the XML schema will soon be dropped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns
Server/src/config/db_ddl.sqlwith the authoritative schema inServer/src/resources/db/openas2-schema.xml. The two had drifted: most notably,db_ddl.sqlwas missing theSENT_FILE_NAMEcolumn thatDbTrackingModulewrites on every outbound, plus several other smaller divergences (column types, defaults).Fixes the bug described in #537 (created alongside this PR).
What's in the change
SENT_FILE_NAME VARCHAR(255)added immediately afterFILE_NAME(same position as in the XML).MSG_ID,PRIOR_MSG_ID,MDN_ID,MDN_RESPONSE,STATE_MSGpromoted from unboundedVARCHARtoLONGVARCHAR, matching the XML.IS_RESEND DEFAULT 'N'RESEND_COUNT DEFAULT 0CREATE_DT DEFAULT CURRENT_TIMESTAMPopenas2-schema.xmlas the single source of truth, so the two files don't drift again.Server/src/test/resources/config/db_ddl.sqlmirrored with the same content to keep the test fixture aligned.Why this matters
create_db_table.sh(the "official" bootstrap path) needs Apache Ant on the host and TCP 9092 open on the H2 server. Hardened deployments routinely:tcp_server_start="false"inDbTrackingModuleso H2 stays in embedded/file mode (no exposed 9092).In those deployments the only viable bootstrap is to apply
db_ddl.sqldirectly viaorg.h2.tools.RunScriptagainst the embedded.mv.dbfile. That's the path this PR fixes.Backwards compatibility
db_ddl.sqland want to upgrade in place:DbTrackingModuleinserts will work after this even without restarting.)How this was tested
db_ddl.sqlusingorg.h2.tools.RunScripton Debian 13 + OpenJDK 21.DbTrackingModulewrote a complete row includingsent_file_name.Notes for reviewers
openas2-schema.xml) remains the source of truth; this PR just brings the convenience SQL up to date with it.db_ddl.sqlfrom the XML at build time so they cannot drift again. Out of scope for this PR — happy to do it as a second PR if maintainers prefer.