修正权限

This commit is contained in:
2026-07-20 21:27:48 +08:00 Unverified
parent c31602593a
commit 76a1b66f53
12 changed files with 584 additions and 12 deletions
+9 -1
View File
@@ -1,3 +1,5 @@
import { synchronizeSqlitePartitions } from './partition-storage.mjs';
export function createSqliteAdapter(context) {
const {
mkdir,
@@ -240,6 +242,9 @@ export function createSqliteAdapter(context) {
if (existingSystem && Number(existingSystem.schema_version || 1) < 15) {
throw new Error('开发数据库结构已升级到 v15,请先运行 npm run reset-db 重建数据库');
}
if (existingSystem && Number(existingSystem.schema_version || 1) < 16) {
connection.prepare('UPDATE schema_metadata SET schema_version = 16 WHERE id = 1').run();
}
if (existingSystem && Number(existingSystem.app_version || 1) < 2) {
const extension = seed();
connection.exec('BEGIN IMMEDIATE');
@@ -400,7 +405,7 @@ export function createSqliteAdapter(context) {
try {
connection.prepare(`
INSERT INTO schema_metadata (id, schema_version, app_version, self_registration_enabled, created_at)
VALUES (1, 15, ?, ?, ?)
VALUES (1, 16, ?, ?, ?)
`).run(Number(initialState.meta?.version || 1), initialState.settings?.selfRegistrationEnabled ? 1 : 0, initialState.meta?.createdAt || new Date().toISOString());
for (const item of buildSeedOperations(initialState)) connection.prepare(item.sql).run(...item.params);
connection.exec('COMMIT');
@@ -410,11 +415,14 @@ export function createSqliteAdapter(context) {
throw error;
}
}
synchronizeSqlitePartitions(connection);
const transaction = async operations => {
connection.exec('BEGIN IMMEDIATE');
try {
for (const item of operations) connection.prepare(item.sql).run(...item.params);
synchronizeSqlitePartitions(connection);
connection.exec('COMMIT');
} catch (error) {
connection.exec('ROLLBACK');