fix postgres error
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"@upstash/redis": "^1.25.0",
|
||||
"@vercel/postgres": "^0.10.0",
|
||||
"@vidstack/react": "^1.12.13",
|
||||
"anime4k-webgpu": "^1.0.0",
|
||||
"artplayer": "^5.3.0",
|
||||
|
||||
771
pnpm-lock.yaml
generated
771
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,17 @@ async function init() {
|
||||
try {
|
||||
// 执行 schema 创建
|
||||
console.log('🔧 Creating database schema...');
|
||||
await sql.unsafe(schemaSql);
|
||||
|
||||
// 将 SQL 脚本按语句分割并逐个执行
|
||||
const statements = schemaSql
|
||||
.split(';')
|
||||
.map(s => s.trim())
|
||||
.filter(s => s.length > 0);
|
||||
|
||||
for (const statement of statements) {
|
||||
await sql.query(statement);
|
||||
}
|
||||
|
||||
console.log('✅ Database schema created successfully!');
|
||||
|
||||
// 创建默认管理员用户
|
||||
|
||||
@@ -77,8 +77,8 @@ class PostgresPreparedStatement implements D1PreparedStatement {
|
||||
try {
|
||||
const convertedQuery = this.convertQuery(this.query);
|
||||
|
||||
// 使用 Vercel Postgres 的 unsafe 方法执行参数化查询
|
||||
const result = await sql.unsafe(convertedQuery, this.params);
|
||||
// 使用 Vercel Postgres 的 query 方法执行参数化查询
|
||||
const result = await sql.query(convertedQuery, this.params);
|
||||
|
||||
if (!result || result.rows.length === 0) return null;
|
||||
|
||||
@@ -100,7 +100,7 @@ class PostgresPreparedStatement implements D1PreparedStatement {
|
||||
try {
|
||||
const convertedQuery = this.convertQuery(this.query);
|
||||
|
||||
const result = await sql.unsafe(convertedQuery, this.params);
|
||||
const result = await sql.query(convertedQuery, this.params);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -126,7 +126,7 @@ class PostgresPreparedStatement implements D1PreparedStatement {
|
||||
try {
|
||||
const convertedQuery = this.convertQuery(this.query);
|
||||
|
||||
const result = await sql.unsafe(convertedQuery, this.params);
|
||||
const result = await sql.query(convertedQuery, this.params);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user