0
# Migration Information and Results
1
2
Comprehensive migration metadata and result objects providing detailed feedback on migration status, execution history, and operation outcomes.
3
4
## Capabilities
5
6
### MigrationInfoService
7
8
```java { .api }
9
/**
10
* Service providing access to migration information
11
*/
12
public interface MigrationInfoService {
13
/** Get all migrations (applied, pending, current) */
14
MigrationInfo[] all();
15
16
/** Get current migration */
17
MigrationInfo current();
18
19
/** Get pending migrations */
20
MigrationInfo[] pending();
21
22
/** Get applied migrations */
23
MigrationInfo[] applied();
24
25
/** Get resolved migrations */
26
MigrationInfo[] resolved();
27
28
/** Get failed migrations */
29
MigrationInfo[] failed();
30
31
/** Get out of order migrations */
32
MigrationInfo[] outOfOrder();
33
}
34
```
35
36
### MigrationInfo
37
38
```java { .api }
39
/**
40
* Information about a single migration
41
*/
42
public interface MigrationInfo extends Comparable<MigrationInfo> {
43
/** The type of migration (SQL, JDBC, etc.) */
44
MigrationType getType();
45
46
/** The checksum of the migration */
47
Integer getChecksum();
48
49
/** The version of the migration */
50
MigrationVersion getVersion();
51
52
/** The description of the migration */
53
String getDescription();
54
55
/** The name of the script to execute for this migration */
56
String getScript();
57
58
/** The state of the migration (PENDING, SUCCESS, etc.) */
59
MigrationState getState();
60
61
/** The timestamp when this migration was installed */
62
Date getInstalledOn();
63
64
/** The user that installed this migration */
65
String getInstalledBy();
66
67
/** The execution time in milliseconds */
68
Integer getExecutionTime();
69
70
/** The rank of this installed migration */
71
Integer getInstalledRank();
72
73
/** Whether this migration can be executed in a transaction */
74
Boolean canExecuteInTransaction();
75
}
76
```
77
78
### Migration States
79
80
```java { .api }
81
/**
82
* The state of a migration
83
*/
84
public enum MigrationState {
85
/** This migration has not been applied yet */
86
PENDING,
87
88
/** This migration has succeeded */
89
SUCCESS,
90
91
/** This migration has failed */
92
FAILED,
93
94
/** This migration succeeded, but it was applied out of order */
95
OUT_OF_ORDER,
96
97
/** This migration succeeded, but it was applied in the future */
98
FUTURE_SUCCESS,
99
100
/** This migration failed, but it was applied in the future */
101
FUTURE_FAILED,
102
103
/** This migration version is newer than the target version */
104
ABOVE_TARGET,
105
106
/** This migration is below the baseline and won't be applied */
107
BELOW_BASELINE,
108
109
/** This is the baseline migration */
110
BASELINE
111
}
112
```
113
114
## Usage Examples
115
116
```java
117
// Get migration information
118
MigrationInfoService infoService = flyway.info();
119
120
// Display all migrations
121
for (MigrationInfo info : infoService.all()) {
122
System.out.printf("%s %s %s %s%n",
123
info.getVersion(),
124
info.getState(),
125
info.getDescription(),
126
info.getInstalledOn());
127
}
128
129
// Check for pending migrations
130
MigrationInfo[] pending = infoService.pending();
131
if (pending.length > 0) {
132
System.out.println("Pending migrations: " + pending.length);
133
}
134
135
// Get current version
136
MigrationInfo current = infoService.current();
137
if (current != null) {
138
System.out.println("Current version: " + current.getVersion());
139
}
140
```