mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-10 17:45:36 +00:00
Remove fallback check for old sqlite file location (#2046)
non breaking as we did fix or hard fail in last version, now we just don't check anymore --------- Co-authored-by: Robert Kaussow <xoxys@rknet.org>
This commit is contained in:
parent
6d373daea0
commit
27c0ff502e
2 changed files with 24 additions and 66 deletions
|
@ -72,10 +72,8 @@ func setupStore(c *cli.Context) (store.Store, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if driver == "sqlite3" {
|
if driver == "sqlite3" {
|
||||||
if newDatasource, err := fallbackSqlite3File(datasource); err != nil {
|
if err := checkSqliteFileExist(datasource); err != nil {
|
||||||
log.Fatal().Err(err).Msg("fallback to old sqlite3 file failed")
|
log.Fatal().Err(err).Msg("check sqlite file")
|
||||||
} else {
|
|
||||||
datasource = newDatasource
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,69 +95,13 @@ func setupStore(c *cli.Context) (store.Store, error) {
|
||||||
return store, nil
|
return store, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove it in v1.1.0
|
func checkSqliteFileExist(path string) error {
|
||||||
// TODO: add it to the "how to migrate from drone docs"
|
_, err := os.Stat(path)
|
||||||
func fallbackSqlite3File(path string) (string, error) {
|
if err != nil && os.IsNotExist(err) {
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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)
|
log.Warn().Msgf("no sqlite3 file found, will create one at '%s'", path)
|
||||||
return path, nil
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupQueue(c *cli.Context, s store.Store) queue.Queue {
|
func setupQueue(c *cli.Context, s store.Store) queue.Queue {
|
||||||
|
|
16
docs/docs/30-administration/20-migrate-from-drone.md
Normal file
16
docs/docs/30-administration/20-migrate-from-drone.md
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# 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 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
|
Loading…
Reference in a new issue