... | @@ -8,27 +8,28 @@ When an application is already deployed and changes to the database are necessar |
... | @@ -8,27 +8,28 @@ When an application is already deployed and changes to the database are necessar |
|
4. Check the `build.gradle.kts` file and find the `h2Version` variable. In the `classpath` variable, replace `VERSION` with the version as it appears in the variable.
|
|
4. Check the `build.gradle.kts` file and find the `h2Version` variable. In the `classpath` variable, replace `VERSION` with the version as it appears in the variable.
|
|
5. Check the following path in your file explorer: `$HOME\.gradle\caches\modules-2\files-2.1\com.h2database\h2\VERSION` and find the folder containing a `.jar` file. Replace `HASH` in the `classpath` variable with the name of this folder.
|
|
5. Check the following path in your file explorer: `$HOME\.gradle\caches\modules-2\files-2.1\com.h2database\h2\VERSION` and find the folder containing a `.jar` file. Replace `HASH` in the `classpath` variable with the name of this folder.
|
|
* If you can't find `modules-2` in the `.gradle/caches` folder, then check the [Gradle Docs](https://docs.gradle.org/current/userguide/directory_layout.html) and replace `modules-2` with the folder labeled `Shared caches (e.g. for artifacts of dependencies)`.
|
|
* If you can't find `modules-2` in the `.gradle/caches` folder, then check the [Gradle Docs](https://docs.gradle.org/current/userguide/directory_layout.html) and replace `modules-2` with the folder labeled `Shared caches (e.g. for artifacts of dependencies)`.
|
|
* Alternatively, you can opt to install the `.jar` file using the relevant version of H2 available on [Maven Central](https://mvnrepository.com/artifact/com.h2database/h2). When executing the migration process (see below), include an extra `--classpath` flag, specifying the file path to the installed `.jar` file.
|
|
* (**EASIER**) Alternatively, you can opt to install the `.jar` file using the relevant version of H2 available on [Maven Central](https://mvnrepository.com/artifact/com.h2database/h2). When executing the migration process (see below), include an extra `--classpath` flag, specifying the file path to the installed `.jar` file.
|
|
6. On a new line add the variable `changeSetAuthor` and set it equal to your GitLab username (usually your NetID).
|
|
6. On a new line add the variable `changeSetAuthor` and set it equal to your GitLab username (usually your NetID).
|
|
|
|
|
|
Another option is to obtain `h2.jar` and `liquibase.zip` from another developer (or from the `.gradle` folder). Then add Liquibase to your path and put the jar under `/usr/local/apps/h2`.
|
|
Another option is to obtain `h2.jar` and `liquibase.zip` from another developer (or from the `.gradle` folder). Then add Liquibase to your path and put the jar under `/usr/local/apps/h2`.
|
|
|
|
|
|
### Create migrations:
|
|
### Create migrations:
|
|
|
|
|
|
0. Make sure your `spring.datasource` in the `application.yaml` has `username: sa` and `password: `
|
|
1. Make sure your `spring.datasource` in the `application.yaml` has `username: sa` and `password:`
|
|
1. Switch to the `dev` branch.
|
|
2. Switch to the `dev` branch.
|
|
2. Make sure the `application.yaml` file has `url: jdbc:h2:file:./testdb-old;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;` in the `datasource` section.
|
|
3. Make sure the `application.yaml` file has `url: jdbc:h2:file:./testdb-old;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;` in the `datasource` section.
|
|
3. Run the project normally, there should now be some `.db` files in the root directory.
|
|
4. Run the project normally, there should now be some `.db` files in the root directory.
|
|
4. Stop the project.
|
|
5. Stop the project.
|
|
5. Switch back to your branch.
|
|
6. Switch back to your branch.
|
|
6. Make sure the `application.yaml` file has `url: jdbc:h2:file:./testdb-new;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;` in the `datasource` section.
|
|
7. Make sure the `application.yaml` file has `url: jdbc:h2:file:./testdb-new;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;` in the `datasource` section.
|
|
7. Run the project normally.
|
|
8. Run the project normally.
|
|
8. Now run this command: `liquibase --changelogFile=new.yaml diff-changelog`, there should now be a file called `new.yaml` in the root directory.
|
|
9. Now run this command: `liquibase --changelogFile=new.yaml diff-changelog`, there should now be a file called `new.yaml` in the root directory.
|
|
9. If you encounter errors during this step, check the `liquibase.properties` file for instructions.
|
|
10. If you encounter errors during this step, check the `liquibase.properties` file for instructions.
|
|
10. Now copy your changes from `new.yaml` to the bottom of `migrations.yaml`. Double check whether the generated changelog makes sense. Sometimes, you might need to add default values or change column types.
|
|
11. Now copy your changes from `new.yaml` to the bottom of `migrations.yaml`. Double check whether the generated changelog makes sense. Sometimes, you might need to add default values or change column types.
|
|
11. Make sure to delete the `new.yaml` file before preforming more migrations.
|
|
12. Make sure to delete the `new.yaml` file before preforming more migrations.
|
|
|
|
|
|
Alternatively you can generate a changelog with the following script:
|
|
Alternatively you can generate a changelog with the following script:
|
|
|
|
|
|
```
|
|
```
|
|
PROJ_DIR=$1
|
|
PROJ_DIR=$1
|
|
RESOURCES_DIR=$PROJ_DIR/src/main/resources
|
|
RESOURCES_DIR=$PROJ_DIR/src/main/resources
|
... | @@ -50,9 +51,11 @@ liquibase \ |
... | @@ -50,9 +51,11 @@ liquibase \ |
|
## Common Errors
|
|
## Common Errors
|
|
|
|
|
|
### No Changelog Generated
|
|
### No Changelog Generated
|
|
|
|
|
|
Liquibase may display a message indicating successful generation of the changelog, but in reality, no changelog exists. This issue is likely due to incorrect url and referenceUrl configurations for your H2 traces. Consider using absolute paths instead of relative paths.
|
|
Liquibase may display a message indicating successful generation of the changelog, but in reality, no changelog exists. This issue is likely due to incorrect url and referenceUrl configurations for your H2 traces. Consider using absolute paths instead of relative paths.
|
|
|
|
|
|
### Incompatible H2 Version
|
|
### Incompatible H2 Version
|
|
|
|
|
|
```
|
|
```
|
|
Caused by: org.h2.mvstore.MVStoreException: The write format 2 is smaller than the supported format 3 [2.2.224/5]
|
|
Caused by: org.h2.mvstore.MVStoreException: The write format 2 is smaller than the supported format 3 [2.2.224/5]
|
|
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996) ~[h2-2.2.224.jar:2.2.224]
|
|
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996) ~[h2-2.2.224.jar:2.2.224]
|
... | | ... | |