From f9270b61d35a33eeaca003e28fea5c819659cf45 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 27 Jul 2023 22:23:58 +0200 Subject: [PATCH 1/3] Add docs about migrating from DroneCI --- .../30-administration/20-migrate-from-drone.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/docs/30-administration/20-migrate-from-drone.md diff --git a/docs/docs/30-administration/20-migrate-from-drone.md b/docs/docs/30-administration/20-migrate-from-drone.md new file mode 100644 index 0000000000..be0fba9842 --- /dev/null +++ b/docs/docs/30-administration/20-migrate-from-drone.md @@ -0,0 +1,14 @@ +# Migrate from Drone to Woodpecker + +## Migrate from Drone >= v1.0.0 + +We currently do not provide a way to do so. +If you are interested or have a custom script to do so, please get in contact with us. + +## Migrate from Drone <= v0.8 + +- Make sure you upgrade to Drone v0.8 +- Upgrade to woodpecker v0.14.4, migration is run on startup +- If you use Sqlite3, rename `drone.sqlite` to `woodpecker.sqlite` and + Rename/Adjust volume-mount/folder from `/var/lib/drone/` to `/var/lib/woodpecker/` +- Upgrade to woodpecker v1.0.0, migration is run on startup From 800e34de09dd6faa1eabb3f1363f47a825adb533 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 27 Jul 2023 22:36:41 +0200 Subject: [PATCH 2/3] Remove Sqlite fallback path func --- cmd/server/setup.go | 74 +++++---------------------------------------- 1 file changed, 8 insertions(+), 66 deletions(-) diff --git a/cmd/server/setup.go b/cmd/server/setup.go index 99a8d76bd9..dd907c9177 100644 --- a/cmd/server/setup.go +++ b/cmd/server/setup.go @@ -72,10 +72,8 @@ func setupStore(c *cli.Context) (store.Store, error) { } if driver == "sqlite3" { - if newDatasource, err := fallbackSqlite3File(datasource); err != nil { - log.Fatal().Err(err).Msg("fallback to old sqlite3 file failed") - } else { - datasource = newDatasource + if err := checkSqliteFileExist(datasource); err != nil { + log.Fatal().Err(err).Msg("check sqlite file") } } @@ -97,69 +95,13 @@ func setupStore(c *cli.Context) (store.Store, error) { return store, nil } -// TODO: remove it in v1.1.0 -// TODO: add it to the "how to migrate from drone docs" -func fallbackSqlite3File(path string) (string, error) { - const dockerDefaultPath = "/var/lib/woodpecker/woodpecker.sqlite" - const dockerDefaultDir = "/var/lib/woodpecker/drone.sqlite" - const dockerOldPath = "/var/lib/drone/drone.sqlite" - const standaloneDefault = "woodpecker.sqlite" - const standaloneOld = "drone.sqlite" - - // custom location was set, use that one - if path != dockerDefaultPath && path != standaloneDefault { - return path, nil - } - - // file is at new default("/var/lib/woodpecker/woodpecker.sqlite") - _, err := os.Stat(dockerDefaultPath) - if err != nil && !os.IsNotExist(err) { - return "", err - } - if err == nil { - return dockerDefaultPath, nil +func checkSqliteFileExist(path string) error { + _, err := os.Stat(path) + if err != nil && os.IsNotExist(err) { + log.Warn().Msgf("no sqlite3 file found, will create one at '%s'", path) + return nil } - - // file is at new default("woodpecker.sqlite") - _, err = os.Stat(standaloneDefault) - if err != nil && !os.IsNotExist(err) { - return "", err - } - if err == nil { - return standaloneDefault, nil - } - - // woodpecker run in standalone mode, file is in same folder but not renamed - _, err = os.Stat(standaloneOld) - if err != nil && !os.IsNotExist(err) { - return "", err - } - if err == nil { - // rename in same folder should be fine as it should be same docker volume - log.Warn().Msgf("found sqlite3 file at '%s' and moved to '%s'", standaloneOld, standaloneDefault) - return standaloneDefault, os.Rename(standaloneOld, standaloneDefault) - } - - // file is in new folder but not renamed - _, err = os.Stat(dockerDefaultDir) - if err != nil && !os.IsNotExist(err) { - return "", err - } - if err == nil { - // rename in same folder should be fine as it should be same docker volume - log.Warn().Msgf("found sqlite3 file at '%s' and moved to '%s'", dockerDefaultDir, dockerDefaultPath) - return dockerDefaultPath, os.Rename(dockerDefaultDir, dockerDefaultPath) - } - - // file is still at old location - _, err = os.Stat(dockerOldPath) - if err == nil { - log.Fatal().Msgf("found sqlite3 file at old path '%s', please move it to '%s' and update your volume path if necessary", dockerOldPath, dockerDefaultPath) - } - - // file does not exist at all - log.Warn().Msgf("no sqlite3 file found, will create one at '%s'", path) - return path, nil + return err } func setupQueue(c *cli.Context, s store.Store) queue.Queue { From d3695e905b2a5db5e88dafa61e7b6b64c27a7e70 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 28 Jul 2023 13:00:44 +0200 Subject: [PATCH 3/3] Update docs/docs/30-administration/20-migrate-from-drone.md Co-authored-by: Robert Kaussow --- docs/docs/30-administration/20-migrate-from-drone.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/docs/30-administration/20-migrate-from-drone.md b/docs/docs/30-administration/20-migrate-from-drone.md index be0fba9842..8bc51f796e 100644 --- a/docs/docs/30-administration/20-migrate-from-drone.md +++ b/docs/docs/30-administration/20-migrate-from-drone.md @@ -7,8 +7,10 @@ If you are interested or have a custom script to do so, please get in contact wi ## Migrate from Drone <= v0.8 -- Make sure you upgrade to Drone v0.8 -- Upgrade to woodpecker v0.14.4, migration is run on startup -- If you use Sqlite3, rename `drone.sqlite` to `woodpecker.sqlite` and - Rename/Adjust volume-mount/folder from `/var/lib/drone/` to `/var/lib/woodpecker/` -- Upgrade to woodpecker v1.0.0, migration is run on startup +- Make sure you are already running Drone v0.8 +- Upgrade to Woodpecker v0.14.4, migration will be done during startup +- If you are using Sqlite3, rename `drone.sqlite` to `woodpecker.sqlite` and + rename or adjust the mount/folder of the volume from `/var/lib/drone/` + to `/var/lib/woodpecker/` +- Upgrade to Woodpecker v1.0.0, the migration will be performed during + startup