Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
19838f8
add migration script
alfeilex Jan 16, 2023
7f86b3c
Remove doEcho current version
alfeilex Jan 16, 2023
650c944
Update ide
alfeilex Jan 16, 2023
ca9a91e
fix shellchecks
alfeilex Jan 16, 2023
491ac8a
Merge branch 'master' into feature/migration
hohwille Jan 19, 2023
8974d06
Merge branch 'devonfw:master' into feature/migration
alfeilex Jan 24, 2023
2b98814
Delete migration
alfeilex Jan 24, 2023
fbe4b23
update migration script and change location
alfeilex Jan 24, 2023
4b41df7
Delete migration
alfeilex Jan 24, 2023
b548765
update migration script and change location
alfeilex Jan 24, 2023
af9aacf
create migrations folder with test script
alfeilex Jan 24, 2023
1c6b0fc
Delete migrations
alfeilex Jan 24, 2023
e761b89
update migrations folder with test script
alfeilex Jan 24, 2023
8c3c328
update migration command
alfeilex Jan 26, 2023
6991ab3
Merge branch 'feature/migration' of https://github.com/alfeilex/ide i…
alfeilex Jan 26, 2023
7119f87
create migration.asciidoc
alfeilex Jan 26, 2023
c41b4ee
Update migration.asciidoc
alfeilex Jan 26, 2023
1688aa8
Update functions.asciidoc
alfeilex Jan 26, 2023
c39e802
fix bug
alfeilex Jan 26, 2023
dbe3d64
fix bug
alfeilex Jan 26, 2023
f21cbd8
Update functions
alfeilex Jan 26, 2023
ac6ec5c
Update CHANGELOG.asciidoc
alfeilex Jan 26, 2023
4b99c0a
Update functions
alfeilex Jan 26, 2023
7ebfddc
Merge branch 'master' into feature/migration
alfeilex Jan 26, 2023
dad11b9
Merge branch 'master' into feature/migration
alfeilex Jan 26, 2023
6969d0b
Merge branch 'master' into feature/migration
alfeilex Jan 31, 2023
de7189e
Merge branch 'devonfw:master' into feature/migration
alfeilex Feb 2, 2023
a75e6fc
Merge branch 'master' into feature/migration
alfeilex Feb 6, 2023
e6d5071
Update CHANGELOG.asciidoc
alfeilex Feb 7, 2023
32e29a3
Merge branch 'master' into feature/migration
alfeilex Feb 7, 2023
a80be85
Merge branch 'master' into feature/migration
alfeilex Feb 7, 2023
5ae34f2
Update migration.asciidoc
hohwille Feb 13, 2023
254b672
Merge branch 'master' into feature/migration
hohwille Feb 13, 2023
e023d59
resolve review comments
alfeilex Feb 27, 2023
de0234e
type fix
alfeilex Feb 27, 2023
4818a28
update version information
alfeilex Feb 27, 2023
5d5e510
update migration scripts in function
alfeilex Feb 27, 2023
da7887a
Update migration
alfeilex Feb 27, 2023
df78f9b
Merge branch 'master' into feature/migration
hohwille Mar 2, 2023
0a63b4f
fixed fallback version
hohwille Mar 2, 2023
5f46cec
update migration with NOT equal and write to .devon.software.version
alfeilex Mar 2, 2023
596affc
update review comments
alfeilex Mar 2, 2023
f3e951a
Merge branch 'master' into feature/migration
alfeilex Mar 2, 2023
a9670e0
fix
alfeilex Mar 2, 2023
1b14f98
Merge branch 'feature/migration' of https://github.com/alfeilex/ide i…
alfeilex Mar 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/ide[devonf

Release with new features and bugfixes:

* https://github.com/devonfw/ide/issues/971[#971]: Ability to run "migration script" on update
* https://github.com/devonfw/ide/issues/991[#991]: Integrate openrewrite feature
* https://github.com/devonfw/ide/issues/1062[#1062]: Migration support for devon4j 2023.01.001
* https://github.com/devonfw/ide/issues/1052[#1052]: Fix leading spaces on MacOS
Expand Down
1 change: 1 addition & 0 deletions documentation/functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ Attention: for one installation package the function doReplaceExtractedSkipSingl
Called with the three parameters path of the file or directory to be moved, the target directory and a backup directory.
The function creates missing directories, makes a backup from the target directory to the backup directory.
Then the files specified in the first parameter are moved to the target directory.
Finally, the link:migration.asciidoc[migration script] is run to migrate the ide to the latest version.

=== doReplaceExtractedSkipSingleFolder
The parameters source directory, target directory, backup directory and possibly a list of files and directories via shell file name expansion (globbing) are passed to the doReplaceExtractedSkipSingleFolder function.
Expand Down
30 changes: 30 additions & 0 deletions documentation/migration.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:toc:
toc::[]

= migration

When we publish a new release, our users can install it to existing devonfw-ide installations via `devon ide update scripts`.
Sometimes we do some structural changes and to avoid "polluting" our scripts with legacy handling code, there is a `migration` script under `${DEVON_IDE_HOME}/scripts` that is automatically executed by `devon ide update scripts` after the new release has been installed.
The `migration` script then executes all potential upgrades in `${DEVON_IDE_HOME}/scripts/migrations/«version»` that are greater or equal to the previously installed version in numerical order.

== upgrade scripts
The `migrations` folder contains a file for each devonfw-ide version that requires an upgrade migration on installation as illustrated by the following example:

.Structure of migrations folder
[subs=+macros]
----
/migrations
├──/ ...
├──/ 2023.03.001
├──/ 2023.03.003
├──/ 2023.12.001
├──/ ...
----

As you can see, the migrations folder contains scripts with specific ide versions.
If no upgrade is required for a new version there will be no migration script so there can be gaps in their numbers.
So if the user runs `devon ide update scripts` on ide with version `«version-x»`, the `migration` script will execute each script in migrations folder from the same version to the latest version in numerical order.

ATTENTION: Since this feature is available with version ´2023.02.001´, older ide's are not affected by the migration.
We try to reach our users with an announcement to upgrade all installations to that version once released.
In case you missed to follow this guidance, you can still manually call `migration 2023.02.001` in your `${DEVON_IDE_HOME}/scripts/` folder to fix it.
7 changes: 6 additions & 1 deletion scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -780,21 +780,26 @@ function doReplaceExtractedFile() {
local filename="${1/*\//}"
local target_dir="${DEVON_IDE_HOME}"
local target="${DEVON_IDE_HOME}/${filename}"
local migration="${DEVON_IDE_HOME}/scripts/migration"
if [ -n "${2}" ]
then
target="${2}"
target_dir="$(dirname "${2}")"
fi
if [ "${target}" = "${DEVON_IDE_HOME}/scripts" ] && doIsWindows
then
(sleep 10;doBackup "${target}" "${3}";doRunCommand "mv '${1}' '${target}'") &
(sleep 10;doBackup "${target}" "${3}";doRunCommand "mv '${1}' '${target}'";doRunCommand "'${migration}'") &
else
doBackup "${target}" "${3}"
if [ ! -d "${target_dir}" ]
then
mkdir -p "${target_dir}"
fi
doRunCommand "mv '${1}' '${target}'"
if [ "${target}" = "${DEVON_IDE_HOME}/scripts" ]
then
doRunCommand "'${migration}'"
fi
fi
}

Expand Down
39 changes: 39 additions & 0 deletions scripts/src/main/resources/scripts/migration
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

# shellcheck source=scripts/functions
source "$(dirname "${0}")"/functions

from_version=2023.01.001
devon_version="${DEVON_IDE_HOME}/.devon.software.version"

if [ -f "${devon_version}" ]
then
from_version="$(cat ${devon_version})"
fi

MIGRATIONS_DIR="${DEVON_IDE_HOME}/scripts/migrations"

if [ -d "${MIGRATIONS_DIR}" ]
then
cd "${MIGRATIONS_DIR}"
for migrate_to_version in $(ls | sort -n)
do
doVersionCompare "${from_version}" "${migrate_to_version}"
result="${?}"
if [ "${result}" -eq 2 ]
then
doEcho "Run migration to version ${migrate_to_version}"
bash "${migrate_to_version}"
migration_result="${?}"
if [ "${migration_result}" -ne 0 ]
then
doAskToContinue "The migration to version ${migrate_to_version} failed. Would you like to continue?"
else
echo "${migrate_to_version}" > "${devon_version}"
doEcho "${devon_version} is set to version ${migrate_to_version}"
fi
fi
done
else
doWarning "Migrations directory does not exist in ${MIGRATIONS_DIR}"
fi