mirror of
https://github.com/usememos/memos.git
synced 2025-03-03 16:53:30 +08:00
chore: move version
pkg to server/version
This commit is contained in:
parent
76801dfa4f
commit
707d1a96eb
3 changed files with 8 additions and 8 deletions
|
@ -7,7 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/usememos/memos/common"
|
||||
"github.com/usememos/memos/server/version"
|
||||
)
|
||||
|
||||
// Profile is the configuration to start main server.
|
||||
|
@ -68,7 +68,7 @@ func GetProfile() (*Profile, error) {
|
|||
|
||||
profile.Data = dataDir
|
||||
profile.DSN = fmt.Sprintf("%s/memos_%s.db", dataDir, profile.Mode)
|
||||
profile.Version = common.GetCurrentVersion(profile.Mode)
|
||||
profile.Version = version.GetCurrentVersion(profile.Mode)
|
||||
|
||||
return &profile, nil
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package common
|
||||
package version
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
@ -10,7 +10,7 @@ import (
|
|||
var Version = "0.4.3"
|
||||
|
||||
// DevVersion is the service current development version.
|
||||
var DevVersion = "0.4.3"
|
||||
var DevVersion = "0.5.0"
|
||||
|
||||
func GetCurrentVersion(mode string) string {
|
||||
if mode == "dev" {
|
|
@ -12,8 +12,8 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/usememos/memos/common"
|
||||
"github.com/usememos/memos/server/profile"
|
||||
"github.com/usememos/memos/server/version"
|
||||
)
|
||||
|
||||
//go:embed migration
|
||||
|
@ -70,7 +70,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
|
|||
return fmt.Errorf("failed to create migration_history table: %w", err)
|
||||
}
|
||||
|
||||
currentVersion := common.GetCurrentVersion(db.profile.Mode)
|
||||
currentVersion := version.GetCurrentVersion(db.profile.Mode)
|
||||
migrationHistory, err := db.FindMigrationHistory(ctx, &MigrationHistoryFind{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -84,7 +84,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
if common.IsVersionGreaterThan(common.GetSchemaVersion(currentVersion), migrationHistory.Version) {
|
||||
if version.IsVersionGreaterThan(version.GetSchemaVersion(currentVersion), migrationHistory.Version) {
|
||||
minorVersionList := getMinorVersionList()
|
||||
|
||||
// backup the raw database file before migration
|
||||
|
@ -101,7 +101,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
|
|||
println("start migrate")
|
||||
for _, minorVersion := range minorVersionList {
|
||||
normalizedVersion := minorVersion + ".0"
|
||||
if common.IsVersionGreaterThan(normalizedVersion, migrationHistory.Version) && common.IsVersionGreaterOrEqualThan(currentVersion, normalizedVersion) {
|
||||
if version.IsVersionGreaterThan(normalizedVersion, migrationHistory.Version) && version.IsVersionGreaterOrEqualThan(currentVersion, normalizedVersion) {
|
||||
println("applying migration for", normalizedVersion)
|
||||
if err := db.applyMigrationForMinorVersion(ctx, minorVersion); err != nil {
|
||||
return fmt.Errorf("failed to apply minor version migration: %w", err)
|
||||
|
|
Loading…
Reference in a new issue