From 9f05e309a26fcbea90dc8bc4e7a6562b20a34b5c Mon Sep 17 00:00:00 2001 From: movsb Date: Sun, 10 Mar 2024 01:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/server/main.go | 3 +-- setup/{init => migration}/init.go | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) rename setup/{init => migration}/init.go (91%) diff --git a/cmd/server/main.go b/cmd/server/main.go index 9efe505b..2b26a26b 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -18,7 +18,6 @@ import ( "github.com/movsb/taoblog/metrics" "github.com/movsb/taoblog/modules/auth" "github.com/movsb/taoblog/service" - inits "github.com/movsb/taoblog/setup/init" "github.com/movsb/taoblog/setup/migration" "github.com/movsb/taoblog/theme" "github.com/movsb/taoblog/theme/modules/canonical" @@ -127,7 +126,7 @@ func initDatabase(cfg *config.Config) *sql.DB { if err := row.Scan(&count); err != nil { if se, ok := err.(sqlite3.Error); ok { if strings.Contains(se.Error(), `no such table`) { - inits.Init(cfg, db) + migration.Init(cfg, db) return db } } diff --git a/setup/init/init.go b/setup/migration/init.go similarity index 91% rename from setup/init/init.go rename to setup/migration/init.go index 0d39d617..d704cb7e 100644 --- a/setup/init/init.go +++ b/setup/migration/init.go @@ -1,4 +1,4 @@ -package inits +package migration import ( "database/sql" @@ -10,7 +10,6 @@ import ( "github.com/movsb/taoblog/config" "github.com/movsb/taoblog/service/models" - "github.com/movsb/taoblog/setup/migration" "github.com/movsb/taorm/taorm" ) @@ -42,7 +41,7 @@ func Init(cfg *config.Config, db *sql.DB) { now := int32(time.Now().Unix()) tx.Model(&models.Option{ Name: `db_ver`, - Value: fmt.Sprint(migration.MaxVersionNumber()), + Value: fmt.Sprint(MaxVersionNumber()), }).MustCreate() tx.Model(&models.Post{ Date: now,