迁移数据库从 SQLite 到 PostgreSQL

- 更新 deno.json 添加 postgres 依赖
- 重构 db/index.ts 使用 PostgreSQL 连接和适配器
- 更新所有路由文件支持异步数据库操作
- 将 SQLite 语法转换为 PostgreSQL 语法
- 添加数据库迁移文档和 schema 文件
This commit is contained in:
ethan.chen
2026-01-08 14:26:27 +08:00
parent 32f7b86f28
commit 2b5b2f1d97
7 changed files with 409 additions and 120 deletions

View File

@@ -2,7 +2,7 @@
###
# @Date: 2025-06-13 16:11:38
# @LastEditors: 陈子健
# @LastEditTime: 2025-06-23 16:56:58
# @LastEditTime: 2025-06-23 17:24:22
# @FilePath: /my-score/honoback/deploy.sh
###
@@ -19,11 +19,15 @@ deno cache main.ts
echo "Creating remote directory..."
ssh $USER@$SERVER "mkdir -p $REMOTE_DIR"
# 同步文件到服务器
echo "Syncing files to server..."
rsync -avz --exclude 'db/media.db' \
--exclude '.git' \
./ $USER@$SERVER:$REMOTE_DIR/
# 1. 远程备份数据库
ssh $USER@$SERVER "cp $REMOTE_DIR/db/media.db $REMOTE_DIR/db/media.db.bak 2>/dev/null || true"
# 2. 同步代码到服务器(只同步白名单内容,且排除 media.db
rsync -avz --exclude='.git/' --exclude='node_modules/' --exclude='db/media.db' \
--include='*.ts' --include='*.json' --include='*.sh' --include='*.service' \
--include='db/' --include='db/*.ts' --include='routes/' --include='routes/*.ts' \
--exclude='*' ./ $USER@$SERVER:$REMOTE_DIR
# 在服务器上安装依赖并重启服务
echo "Installing and starting systemd service..."