Remove a model field
Remove a stored field only after its consumers and data-retention requirements are resolved. Applying the generated
migration drops the column and its values. This example removes the invented trackingCode added in
Add a field; rehearse it in that disposable application first.
Remove the consumers before the column
Find every use of the field in forms, headers, roles, rules, queues, workflow effects, letters, imports, reports, Java and tests. Remove or replace each use according to the intended behavior. Include external integrations in the review. A text search helps find references but cannot prove that no consumer remains.
If you added trackingCode to case.request.yml, remove it from that form. Update the persistence test that calls
its generated getter/setter. Keep tests of the remaining fields; deleting a test is not evidence that the app still
works. Resolve any export, archive or retained-copy requirement before applying a destructive migration.
Declare the removal
Delete the field from fields in src/main/jcm/model/Request.yml and list it under top-level removed:
entity: Request
instance-name: title
fields:
title: {type: text, length: 200, required: true}
receivedOn: {type: date}
urgent: {type: boolean, default: false}
urgencyReason: {type: text, length: 1000, label: Why it is urgent}
removed: [trackingCode]
Without the mark, jcm changelog refuses a field present in schema.json but missing from the model. Use the mark
only for the intended field. Dropping an entire entity/table is not supported by this operation.
jcm changelog
git status --short
Inspect the new XML file and updated schema.json. The migration should drop TRACKING_CODE and its dependencies,
not another field or table. Never delete an old migration or edit schema.json by hand to make the column disappear.
After generation, remove the now-consumed removed: [trackingCode] line from the model. If the list names other
pending removals, handle each deliberately. A repeated jcm changelog should write no new migration.
jcm changelog
jcm check
All four check stages should pass with the remaining fields. Review the model, new XML, snapshot, consumers and tests as one change. Rehearse upgrading a disposable prior database with invented data and verify that the intended column is gone while other records and fields remain. Do not use a new empty database as the only deletion rehearsal.
Generating the XML is not database deletion; starting the application against a database applies pending migrations. Schedule the actual change through your release process after the data decision and recovery plan are approved. Reverting the application image does not restore a dropped column's values.