Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: move `version` pkg to `server/version`

Steven707d1a96eb47
diff --git a/server/profile/profile.go b/server/profile/profile.go
index 2bd8232a1..0b23ff8a5 100644
--- a/server/profile/profile.go
+++ b/server/profile/profile.go
@@ -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
}
diff --git a/common/version.go b/server/version/version.go
similarity index 97%
rename from common/version.go
rename to server/version/version.go
index 8c92f4063..24d3fe111 100644
--- a/common/version.go
+++ b/server/version/version.go
@@ -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" {
diff --git a/store/db/db.go b/store/db/db.go
index 22c29e72f..24cd75f8d 100644
--- a/store/db/db.go
+++ b/store/db/db.go
@@ -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)