Skip to content

Commit 381f6fc

Browse files
committed
Update documentation
- Code format
1 parent 39f6a47 commit 381f6fc

37 files changed

+246
-233
lines changed

src/docs/guide/configuration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The configuration for this data source would be:
4242
grails.plugin.databasemigration.reports.updateOnStart = true
4343
grails.plugin.databasemigration.reports.changelogFileName = changelog-second.groovy
4444
----
45+
4546
The configuration for all data sources with same db schema would be:
4647
[source,groovy]
4748
----

src/docs/guide/generalUsage.adoc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ You have a few options with `dbm-gorm-diff`:
2121
2222
Regardless of which approach you use, be sure to inspect generated changes and adjust as necessary.
2323

24-
2524
=== Autorun on start
2625

27-
2826
Since Liquibase maintains a record of changes that have been applied, you can avoid manually updating the database by taking advantage of the plugin's auto-run feature. By default this is disabled, but you can enable it by adding
2927

3028
[source,groovy]
@@ -67,17 +65,17 @@ import liquibase.database.Database
6765
6866
class MigrationCallbacks {
6967
70-
void beforeStartMigration(Database Database) {
71-
...
72-
}
68+
void beforeStartMigration(Database Database) {
69+
...
70+
}
7371
74-
void onStartMigration(Database database, Liquibase liquibase, String changelogName) {
75-
...
76-
}
72+
void onStartMigration(Database database, Liquibase liquibase, String changelogName) {
73+
...
74+
}
7775
78-
void afterMigrations(Database Database) {
79-
...
80-
}
76+
void afterMigrations(Database Database) {
77+
...
78+
}
8179
}
8280
----
8381

@@ -88,6 +86,6 @@ Register it in resources.groovy:
8886
import com.mycompany.myapp.MigrationCallbacks
8987
9088
beans = {
91-
migrationCallbacks(MigrationCallbacks)
89+
migrationCallbacks(MigrationCallbacks)
9290
}
9391
----

src/docs/guide/gettingStarted.adoc

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ The first step is to add a dependency for the plugin in `build.gradle`:
33
[source,groovy,subs="attributes"]
44
----
55
buildscript {
6-
dependencies {
7-
...
8-
classpath 'org.graceframework.plugins:database-migration:{version}'
9-
}
6+
dependencies {
7+
...
8+
classpath 'org.graceframework.plugins:database-migration:{version}'
9+
}
1010
}
1111
1212
dependencies {
13-
...
14-
implementation 'org.graceframework.plugins:database-migration:{version}'
13+
...
14+
implementation 'org.graceframework.plugins:database-migration:{version}'
1515
}
1616
----
1717

@@ -20,8 +20,8 @@ It is also recommended to add a direct dependency to liquibase because Spring Bo
2020
[source,groovy,subs="attributes"]
2121
----
2222
dependencies {
23-
...
24-
implementation 'org.liquibase:liquibase-core'
23+
...
24+
implementation 'org.liquibase:liquibase-core'
2525
}
2626
----
2727

@@ -46,16 +46,17 @@ Next you'll need to create an initial changelog. You can use Liquibase XML or th
4646
Depending on the state of your database and code, you have two options; either create a changelog from the database or create it from your domain classes. The decision tends to be based on whether you prefer to design the database and adjust the domain classes to work with it, or to design your domain classes and use Hibernate to create the corresponding database structure.
4747

4848
To create a changelog from the database, use the link:../ref/Rollback%20Scripts/dbm-generate-changelog.html[dbm-generate-changelog] script:
49-
[source,groovy]
49+
50+
[source,console]
5051
----
51-
grace dbm-generate-changelog changelog.groovy
52+
$ grace dbm-generate-changelog changelog.groovy
5253
----
5354

5455
or
5556

56-
[source,groovy]
57+
[source,console]
5758
----
58-
grace dbm-generate-changelog changelog.xml
59+
$ grace dbm-generate-changelog changelog.xml
5960
----
6061

6162
depending on whether you prefer the Groovy DSL or XML. The filename is relative to the changelog base folder, which defaults to `app/migrations`.
@@ -67,39 +68,39 @@ grails.plugin.databasemigration.changelogFileName = 'changelog.xml'
6768
----
6869

6970
Since the database is already correct, run the link:../ref/Maintenance%20Scripts/dbm-changelog-sync.html[dbm-changelog-sync] script to record that the changes have already been applied:
70-
[source,groovy]
71+
[source,console]
7172
----
72-
grace dbm-changelog-sync
73+
$ grace dbm-changelog-sync
7374
----
7475

7576
Running this script is primarily a no-op except that it records the execution(s) in the Liquibase DATABASECHANGELOG table.
7677

7778
To create a changelog from your domain classes, use the link:../ref/Rollback%20Scripts/dbm-generate-gorm-changelog.html[dbm-generate-gorm-changelog] script:
7879

79-
[source,groovy]
80+
[source,console]
8081
----
81-
grace dbm-generate-gorm-changelog changelog.groovy
82+
$ grace dbm-generate-gorm-changelog changelog.groovy
8283
----
8384

8485
or
8586

86-
[source,groovy]
87+
[source,console]
8788
----
88-
grace dbm-generate-gorm-changelog changelog.xml
89+
$ grace dbm-generate-gorm-changelog changelog.xml
8990
----
9091

9192
If you haven't created the database yet, run the link:../ref/Update%20Scripts/dbm-update.html[dbm-update] script to create the corresponding tables:
9293

93-
[source,groovy]
94+
[source,console]
9495
----
95-
grace dbm-update
96+
$ grace dbm-update
9697
----
9798

9899
or the link:../ref/Maintenance%20Scripts/dbm-changelog-sync.html[dbm-changelog-sync] script if the database is already in sync with your code:
99100

100-
[source,groovy]
101+
[source,console]
101102
----
102-
grace dbm-changelog-sync
103+
$ grace dbm-changelog-sync
103104
----
104105

105106
*Source control*

src/docs/guide/groovyChanges.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@ This is the general format of a Groovy-based change; all inner tags and methods
1010
----
1111
databaseChangeLog = {
1212
13-
changeSet(author: '...', id: '...') {
13+
changeSet(author: '...', id: '...') {
1414
15-
grailsChange {
16-
init {
17-
// arbitrary initialization code; note that no
18-
// database or connection is available
19-
}
15+
grailsChange {
16+
init {
17+
// arbitrary initialization code; note that no
18+
// database or connection is available
19+
}
2020
21-
validate {
22-
// can call warn(String message) to log a warning
23-
// or error(String message) to stop processing
24-
}
21+
validate {
22+
// can call warn(String message) to log a warning
23+
// or error(String message) to stop processing
24+
}
2525
26-
change {
27-
// arbitrary code; make changes directly and/or return a
28-
// SqlStatement using the sqlStatement(SqlStatement sqlStatement)
29-
// method or multiple with sqlStatements(List sqlStatements)
26+
change {
27+
// arbitrary code; make changes directly and/or return a
28+
// SqlStatement using the sqlStatement(SqlStatement sqlStatement)
29+
// method or multiple with sqlStatements(List sqlStatements)
3030
31-
confirm 'change confirmation message'
32-
}
31+
confirm 'change confirmation message'
32+
}
3333
34-
rollback {
35-
// arbitrary code; make rollback changes directly and/or
36-
// return a SqlStatement using the sqlStatement(SqlStatement sqlStatement)
37-
// method or multiple with sqlStatements(List sqlStatements)
34+
rollback {
35+
// arbitrary code; make rollback changes directly and/or
36+
// return a SqlStatement using the sqlStatement(SqlStatement sqlStatement)
37+
// method or multiple with sqlStatements(List sqlStatements)
3838
39-
confirm 'rollback confirmation message'
40-
}
39+
confirm 'rollback confirmation message'
40+
}
4141
42-
confirm 'confirmation message'
42+
confirm 'confirmation message'
4343
44-
checkSum 'override value for checksum'
45-
}
44+
checkSum 'override value for checksum'
45+
}
4646
47-
}
47+
}
4848
}
4949
----
5050

src/docs/guide/groovyPreconditions.adoc

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,34 @@ This is the general format of a Groovy-based precondition:
88
----
99
databaseChangeLog = {
1010
11-
changeSet(author: '...', id: '...') {
11+
changeSet(author: '...', id: '...') {
1212
13-
preConditions {
13+
preConditions {
1414
15-
grailsPrecondition {
15+
grailsPrecondition {
1616
17-
check {
17+
check {
18+
// use an assertion
19+
assert x == x
1820
19-
// use an assertion
20-
assert x == x
21+
// use an assertion with an error message
22+
assert y == y : 'value cannot be 237'
2123
22-
// use an assertion with an error message
23-
assert y == y : 'value cannot be 237'
24+
// call the fail method
25+
if (x != x) {
26+
fail 'x != x'
27+
}
2428
25-
// call the fail method
26-
if (x != x) {
27-
fail 'x != x'
28-
}
29+
// throw an exception (the fail method is preferred)
30+
if (y != y) {
31+
throw new RuntimeException('y != y')
32+
}
33+
}
2934
30-
// throw an exception (the fail method is preferred)
31-
if (y != y) {
32-
throw new RuntimeException('y != y')
33-
}
3435
}
3536
36-
}
37-
38-
}
39-
}
37+
}
38+
}
4039
}
4140
----
4241

src/docs/ref/Diff Scripts/dbm-diff.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ If a filename parameter is specified then the output will be written to the name
1313
File are written to the migrations folder, so specify the filename relative to the migrations folder (`app/migrations` by default).
1414

1515
Usage:
16-
[source,java]
16+
[source,console]
1717
----
18-
grace <<environment>> dbm-diff <<otherEnv>> <<filename>> --defaultSchema=<<defaultSchema>> --dataSource=<<dataSource>> --add
18+
$ grace <<environment>> dbm-diff <<otherEnv>> <<filename>> --defaultSchema=<<defaultSchema>> --dataSource=<<dataSource>> --add
1919
----
2020

2121
Required arguments:
@@ -30,14 +30,14 @@ Optional arguments:
3030
* `dataSource` - If provided will run the script for the specified dataSource. Not needed for the default dataSource.
3131

3232
NOTE: Note that the `defaultSchema` and `dataSource` parameter name and value must be quoted if executed in Windows, e.g.
33-
[source,groovy]
33+
[source,console]
3434
----
35-
grace dbm-diff "--defaultSchema=<<defaultSchema>>" "--dataSource=<<dataSource>>"
35+
$ grace dbm-diff "--defaultSchema=<<defaultSchema>>" "--dataSource=<<dataSource>>"
3636
----
3737

3838
NOTE: For the `dataSource` parameter, if the data source is configured as `reports` underneath the `dataSources` key in `application.[yml|groovy]`, the value should be `reports`.
3939

40-
[source,groovy]
40+
[source,console]
4141
----
4242
--dataSource=reports
4343
----

src/docs/ref/Diff Scripts/dbm-gorm-diff.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Doesn't modify any existing files - you need to manually merge the output into t
1717
You can configure database objects to be ignored by this script - either in the GORM classes or in the target database. For example you may want domain objects that are transient, or you may have externally-managed tables, keys, etc. that you want left alone by the diff script. The configuration name for these ignored objects is `grails.plugin.databasemigration.ignoredObjects`, whose value is a list of strings.
1818

1919
Usage:
20-
[source,java]
20+
[source,console]
2121
----
22-
grace <<environment>> dbm-gorm-diff <<filename>> --defaultSchema=<<defaultSchema>> --dataSource=<<dataSource>> --add
22+
$ grace <<environment>> dbm-gorm-diff <<filename>> --defaultSchema=<<defaultSchema>> --dataSource=<<dataSource>> --add
2323
----
2424

2525
Required arguments: _none_ .
@@ -32,14 +32,14 @@ Optional arguments:
3232
* `dataSource` - if provided will run the script for the specified dataSource. Not needed for the default dataSource.
3333

3434
NOTE: Note that the `defaultSchema` and `dataSource` parameter name and value must be quoted if executed in Windows, e.g.
35-
[source,groovy]
35+
[source,console]
3636
----
37-
grace dbm-gorm-diff "--defaultSchema=<<defaultSchema>>" "--dataSource=<<dataSource>>"
37+
$ grace dbm-gorm-diff "--defaultSchema=<<defaultSchema>>" "--dataSource=<<dataSource>>"
3838
----
3939

4040
NOTE: For the `dataSource` parameter, if the data source is configured as `reports` underneath the `dataSources` key in `application.[yml|groovy]`, the value should be `reports`.
4141

42-
[source,groovy]
42+
[source,console]
4343
----
4444
--dataSource=reports
4545
----

src/docs/ref/Documentation Scripts/dbm-db-doc.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Generates Javadoc-like documentation based on current database and change log.
99
Writes to the folder specified by the `destination` parameter, or to the `grails.plugin.databasemigration.dbDocLocation` configuration option (defaults to `target/dbdoc`).
1010

1111
Usage:
12-
[source,java]
12+
[source,console]
1313
----
14-
grace <<environment>> dbm-db-doc <<destination>> --contexts=<<contexts>> --dataSource=<<dataSource>>
14+
$ grace <<environment>> dbm-db-doc <<destination>> --contexts=<<contexts>> --dataSource=<<dataSource>>
1515
----
1616

1717
Required arguments: _none_ .
@@ -23,14 +23,14 @@ Optional arguments:
2323
* `dataSource` - if provided will run the script for the specified dataSource. Not needed for the default dataSource.
2424

2525
NOTE: Note that the `contexts` and `dataSource` parameter name and value must be quoted if executed in Windows, e.g.
26-
[source,groovy]
26+
[source,console]
2727
----
28-
grace dbm-db-doc "--contexts=<<contexts>>" "--dataSource=<<dataSource>>"
28+
$ grace dbm-db-doc "--contexts=<<contexts>>" "--dataSource=<<dataSource>>"
2929
----
3030

3131
NOTE: For the `dataSource` parameter, if the data source is configured as `reports` underneath the `dataSources` key in `application.[yml|groovy]`, the value should be `reports`.
3232

33-
[source,groovy]
33+
[source,console]
3434
----
3535
--dataSource=reports
3636
----

src/docs/ref/Maintenance Scripts/dbm-add-migration.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ This script provides a template in which to place your migration behaviour code,
1010
Grace code or raw SQL.
1111

1212
Usage:
13-
[source,java]
13+
[source,console]
1414
----
15-
grace <<environment>> dbm-add-migration <<migrationName>>
15+
$ grace <<environment>> dbm-add-migration <<migrationName>>
1616
----
1717

1818
Required arguments:

0 commit comments

Comments
 (0)