Skip to content

Commit 4e5eae6

Browse files
committed
docs: order clarification
1 parent 2f78851 commit 4e5eae6

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

docs/changes/anatomy-and-structure.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ The `order` determines when the Change executes relative to others.
3838
- Minimum 4 digits recommended for future expansion
3939
- Determines execution order across all target systems
4040
- Cannot be changed once deployed
41+
42+
:::warning Order Field Rules
43+
- The `order` must be specified in **at least one** of these places:
44+
- In the file/class name following the pattern `_ORDER_DescriptiveName.[java|yaml]`
45+
- In the annotation (@Change) or YAML structure
46+
- Both are optional, but **at least one is required**
47+
- If order is specified in **both** locations, they **must be identical**
48+
- For file/class names:
49+
- Must start with underscore `_`
50+
- Order is extracted between the first `_` and the last `_`
51+
- Allows intermediate underscores (e.g., `_2025_09_01_09_00_0001_CreateUserTable.java`)
52+
- Order extracted: everything between first and last underscore (e.g., `2025_09_01_09_00_0001`)
53+
- Orders are evaluated in alphanumeric order
54+
:::
55+
56+
For recommendations on order field placement and naming patterns, see [Best Practices - Naming Patterns](./best-practices#follow-consistent-naming-patterns).
4157
____
4258
### `author` - Responsibility tracking
4359
Identifies who is responsible for this change.

docs/changes/best-practices.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,36 @@ public void removeEmailIndexAndRevertSchema(MongoDatabase db) { }
239239
### Follow consistent naming patterns
240240

241241
**File names:**
242-
- Use `_XXXX_DescriptiveName` format
243-
- Match the order in `@Change` annotation
242+
- Use `_ORDER_DescriptiveName` format where ORDER is extracted between first and last underscores
243+
- When using this naming pattern, the order in `@Change` annotation or YAML is optional
244244
- Use PascalCase for class names
245+
- Pattern supports flexible ordering: timestamps, hierarchical numbering, etc.
245246

246247
**Good examples:**
247248
```
248249
_0001_CreateUserIndexes.java
249250
_0002_MigrateUserData.java
250251
_0003_AddUserPreferences.java
251252
_0100_OptimizeUserQueries.java
253+
_2025_09_01_MigrateToNewFormat.java
254+
_2025_09_01_09_00_0001_ComplexMigration.yaml
252255
```
253256

257+
:::tip Recommendation
258+
We recommend specifying the order in the file/class name rather than in the annotation/yaml:
259+
- Makes execution order immediately visible when browsing folders
260+
- Easier to identify and list changes in their location
261+
- Reduces redundancy and potential mismatches
262+
- Supports flexible ordering schemes (timestamps, hierarchical numbering, etc.)
263+
264+
Examples:
265+
- `_0001_CreateUserTable.java` → order: "0001" (no need for order in @Change)
266+
- `_2025_09_01_MigrateData.yaml` → order: "2025_09_01" (no need for order in YAML)
267+
- `_2025_09_01_09_00_0001_ComplexChange.java` → order: "2025_09_01_09_00_0001"
268+
:::
269+
270+
271+
For detailed rules about order field placement (filename vs annotation), see [Anatomy & Structure - Order](./anatomy-and-structure#order---execution-sequence).
254272

255273
---
256274

docs/changes/types-and-implementation.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ Code-based Changes are written in Java, Kotlin, or Groovy with annotations. They
5656
5757
```java
5858
@TargetSystem("user-database")
59-
@Change(id = "migrate-user-emails", order = "0001", author = "data-team")
59+
@Change(id = "migrate-user-emails", author = "data-team") // order extracted from filename
6060
public class _0001_MigrateUserEmails {
61-
61+
6262
@Apply
6363
public void apply(MongoDatabase database, ClientSession session) {
6464
// Custom implementation logic with full programmatic control
@@ -67,7 +67,7 @@ public class _0001_MigrateUserEmails {
6767
new Document("email", new Document("$exists", true)),
6868
new Document("$set", new Document("emailVerified", false)));
6969
}
70-
70+
7171
@Rollback
7272
public void rollback(MongoDatabase database, ClientSession session) {
7373
// Rollback logic
@@ -102,7 +102,12 @@ src/main/java/com/yourapp/changes/
102102

103103
### Best practices:
104104
- **Keep together**: Store both code and template files in the same directory
105-
- **Consistent naming**: Follow `_XXXX_DescriptiveName` pattern for both types
105+
- **Consistent naming**: Follow `_ORDER_DescriptiveName` pattern for both types
106+
- **Order in filename**: When using the naming pattern, order in annotation/yaml is optional
107+
108+
:::info Order Field Rules
109+
When using the `_ORDER_DescriptiveName` pattern, the order field in annotations or YAML becomes optional. For complete rules about order field placement, see [Anatomy & Structure - Order](./anatomy-and-structure#order---execution-sequence).
110+
:::
106111

107112
## Template development
108113

docs/flamingock-library-config/setup-and-stages.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,28 @@ To ensure clarity and enforce ordering, we recommend naming changes using the fo
273273
```
274274
_0001_CREATE_CLIENTS_TABLE.java
275275
_0002_ADD_INDEX_TO_EMAIL.yaml
276+
_2025_09_01_MIGRATE_DATA.java
277+
_2025_09_01_09_00_0001_COMPLEX_CHANGE.yaml
276278
```
277279

278-
- `XXXX`: The execution order of the change
280+
- `ORDER`: The execution order extracted between the first `_` and last `_` (supports timestamps, hierarchical numbering)
279281
- `CHANGE_NAME`: Descriptive name of what the change does
280282

281283
This convention:
284+
- **Eliminates the need for order in annotations/YAML** - the order is extracted from the filename
285+
- Makes execution order immediately visible when browsing folders
282286
- Works across both code-based and template-based formats
283-
- Makes the execution order obvious at a glance
287+
- Supports flexible ordering schemes (simple numbers, dates, timestamps)
284288
- Ensures consistent naming and project hygiene
285289

286290
:::tip
287291
While Java typically avoids underscores and leading digits, change units are not traditional classes. Prioritizing **readability and order** is more valuable in this context.
288292
:::
289293

294+
:::info Complete Order Field Rules
295+
For detailed rules about order field placement and how filename order works with annotations, see [Change Anatomy - Order](../changes/anatomy-and-structure#order---execution-sequence).
296+
:::
297+
290298

291299

292300
## 🛠 Troubleshooting

0 commit comments

Comments
 (0)