fix(api): 移除对只读数据库的ALTER TABLE操作
由于数据库是只读的,移除ExportsAPI中尝试修改表结构的ensureOwnerColumn方法调用 同时从Dockerfile中移除APP_ENV=prod的环境变量设置
This commit is contained in:
parent
1fbc81f88c
commit
18841ea58a
|
|
@ -13,6 +13,5 @@ COPY --from=build /app/web /app/web
|
|||
COPY --from=build /app/server/config.test.yaml /app/server/config.test.yaml
|
||||
COPY --from=build /app/server/config.prod.yaml /app/server/config.prod.yaml
|
||||
RUN mkdir -p /app/storage/export
|
||||
ENV APP_ENV=prod
|
||||
EXPOSE 8077
|
||||
ENTRYPOINT ["/app/bin/marketing-data-server"]
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,6 @@ import (
|
|||
"marketing-system-data-tool/server/internal/api"
|
||||
"marketing-system-data-tool/server/internal/config"
|
||||
"marketing-system-data-tool/server/internal/db"
|
||||
"marketing-system-data-tool/server/internal/migrate"
|
||||
"marketing-system-data-tool/server/internal/logging"
|
||||
"net/http"
|
||||
"time"
|
||||
|
|
@ -14,6 +13,7 @@ import (
|
|||
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
log.Println("APP_ENV:", os.Getenv("APP_ENV"))
|
||||
if cfg.YMTKeyDecryptKeyB64 != "" { os.Setenv("YMT_KEY_DECRYPT_KEY_B64", cfg.YMTKeyDecryptKeyB64) }
|
||||
_ = logging.Init("log")
|
||||
log.Println("connecting YMT MySQL:", cfg.YMTDB.Host+":"+cfg.YMTDB.Port, "db", cfg.YMTDB.Name, "user", cfg.YMTDB.User)
|
||||
|
|
@ -32,13 +32,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if cfg.YMTDB.DSN() != "" {
|
||||
if err := migrate.Apply(ymt); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
log.Println("skip migrations: YMT DSN missing")
|
||||
}
|
||||
_ = ymt
|
||||
r := api.NewRouter(ymt, marketing)
|
||||
addr := ":" + func() string {
|
||||
s := cfg.Port
|
||||
|
|
|
|||
|
|
@ -61,10 +61,8 @@ func ExportsHandler(meta, marketing *sql.DB) http.Handler {
|
|||
})
|
||||
}
|
||||
|
||||
func (a *ExportsAPI) ensureOwnerColumn() {
|
||||
// Try to add owner_id column if not exists; ignore errors
|
||||
_, _ = a.meta.Exec("ALTER TABLE export_jobs ADD COLUMN owner_id BIGINT UNSIGNED NOT NULL DEFAULT 0")
|
||||
}
|
||||
// owner_id 列在只读库不做运行时变更,避免 ALTER TABLE 触发错误
|
||||
func (a *ExportsAPI) ensureOwnerColumn() {}
|
||||
|
||||
type ExportPayload struct {
|
||||
TemplateID uint64 `json:"template_id"`
|
||||
|
|
@ -947,7 +945,6 @@ func toString(v interface{}) string {
|
|||
}
|
||||
}
|
||||
func (a *ExportsAPI) list(w http.ResponseWriter, r *http.Request) {
|
||||
a.ensureOwnerColumn()
|
||||
q := r.URL.Query()
|
||||
page := 1
|
||||
size := 15
|
||||
|
|
|
|||
Loading…
Reference in New Issue