Skip to content

Commit 27c0ff5

Browse files
6543xoxys
andauthored
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>
1 parent 6d373da commit 27c0ff5

File tree

2 files changed

+24
-66
lines changed

2 files changed

+24
-66
lines changed

cmd/server/setup.go

+8-66
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ func setupStore(c *cli.Context) (store.Store, error) {
7272
}
7373

7474
if driver == "sqlite3" {
75-
if newDatasource, err := fallbackSqlite3File(datasource); err != nil {
76-
log.Fatal().Err(err).Msg("fallback to old sqlite3 file failed")
77-
} else {
78-
datasource = newDatasource
75+
if err := checkSqliteFileExist(datasource); err != nil {
76+
log.Fatal().Err(err).Msg("check sqlite file")
7977
}
8078
}
8179

@@ -97,69 +95,13 @@ func setupStore(c *cli.Context) (store.Store, error) {
9795
return store, nil
9896
}
9997

100-
// TODO: remove it in v1.1.0
101-
// TODO: add it to the "how to migrate from drone docs"
102-
func fallbackSqlite3File(path string) (string, error) {
103-
const dockerDefaultPath = "/var/lib/woodpecker/woodpecker.sqlite"
104-
const dockerDefaultDir = "/var/lib/woodpecker/drone.sqlite"
105-
const dockerOldPath = "/var/lib/drone/drone.sqlite"
106-
const standaloneDefault = "woodpecker.sqlite"
107-
const standaloneOld = "drone.sqlite"
108-
109-
// custom location was set, use that one
110-
if path != dockerDefaultPath && path != standaloneDefault {
111-
return path, nil
112-
}
113-
114-
// file is at new default("/var/lib/woodpecker/woodpecker.sqlite")
115-
_, err := os.Stat(dockerDefaultPath)
116-
if err != nil && !os.IsNotExist(err) {
117-
return "", err
118-
}
119-
if err == nil {
120-
return dockerDefaultPath, nil
98+
func checkSqliteFileExist(path string) error {
99+
_, err := os.Stat(path)
100+
if err != nil && os.IsNotExist(err) {
101+
log.Warn().Msgf("no sqlite3 file found, will create one at '%s'", path)
102+
return nil
121103
}
122-
123-
// file is at new default("woodpecker.sqlite")
124-
_, err = os.Stat(standaloneDefault)
125-
if err != nil && !os.IsNotExist(err) {
126-
return "", err
127-
}
128-
if err == nil {
129-
return standaloneDefault, nil
130-
}
131-
132-
// woodpecker run in standalone mode, file is in same folder but not renamed
133-
_, err = os.Stat(standaloneOld)
134-
if err != nil && !os.IsNotExist(err) {
135-
return "", err
136-
}
137-
if err == nil {
138-
// rename in same folder should be fine as it should be same docker volume
139-
log.Warn().Msgf("found sqlite3 file at '%s' and moved to '%s'", standaloneOld, standaloneDefault)
140-
return standaloneDefault, os.Rename(standaloneOld, standaloneDefault)
141-
}
142-
143-
// file is in new folder but not renamed
144-
_, err = os.Stat(dockerDefaultDir)
145-
if err != nil && !os.IsNotExist(err) {
146-
return "", err
147-
}
148-
if err == nil {
149-
// rename in same folder should be fine as it should be same docker volume
150-
log.Warn().Msgf("found sqlite3 file at '%s' and moved to '%s'", dockerDefaultDir, dockerDefaultPath)
151-
return dockerDefaultPath, os.Rename(dockerDefaultDir, dockerDefaultPath)
152-
}
153-
154-
// file is still at old location
155-
_, err = os.Stat(dockerOldPath)
156-
if err == nil {
157-
log.Fatal().Msgf("found sqlite3 file at old path '%s', please move it to '%s' and update your volume path if necessary", dockerOldPath, dockerDefaultPath)
158-
}
159-
160-
// file does not exist at all
161-
log.Warn().Msgf("no sqlite3 file found, will create one at '%s'", path)
162-
return path, nil
104+
return err
163105
}
164106

165107
func setupQueue(c *cli.Context, s store.Store) queue.Queue {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Migrate from Drone to Woodpecker
2+
3+
## Migrate from Drone >= v1.0.0
4+
5+
We currently do not provide a way to do so.
6+
If you are interested or have a custom script to do so, please get in contact with us.
7+
8+
## Migrate from Drone <= v0.8
9+
10+
- Make sure you are already running Drone v0.8
11+
- Upgrade to Woodpecker v0.14.4, migration will be done during startup
12+
- If you are using Sqlite3, rename `drone.sqlite` to `woodpecker.sqlite` and
13+
rename or adjust the mount/folder of the volume from `/var/lib/drone/`
14+
to `/var/lib/woodpecker/`
15+
- Upgrade to Woodpecker v1.0.0, the migration will be performed during
16+
startup

0 commit comments

Comments
 (0)