chore(native): ensure SQLite data dir exists in setup and at runtime; keep native paths consistent under /opt/picpeak/app
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m38s
Test and Lint / frontend-test (push) Successful in 2m3s
Version and Release / version-bump (push) Successful in 59s
Version and Release / trigger-drone (push) Successful in 3s
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m38s
Test and Lint / frontend-test (push) Successful in 2m3s
Version and Release / version-bump (push) Successful in 59s
Version and Release / trigger-drone (push) Successful in 3s
This commit is contained in:
@@ -1,7 +1,28 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const knex = require('knex');
|
const knex = require('knex');
|
||||||
const knexConfig = require('../../knexfile');
|
const knexConfig = require('../../knexfile');
|
||||||
const logger = require('../utils/logger');
|
const logger = require('../utils/logger');
|
||||||
|
|
||||||
|
// Ensure SQLite directory exists when using file-based DB (native installs)
|
||||||
|
try {
|
||||||
|
const isPostgres = knexConfig && knexConfig.client === 'pg';
|
||||||
|
if (!isPostgres && knexConfig && knexConfig.connection) {
|
||||||
|
const filename = typeof knexConfig.connection === 'object'
|
||||||
|
? knexConfig.connection.filename
|
||||||
|
: (typeof knexConfig.connection === 'string' ? knexConfig.connection : null);
|
||||||
|
if (filename && typeof filename === 'string') {
|
||||||
|
const dir = path.dirname(filename);
|
||||||
|
if (dir && dir !== '.') {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Non-fatal: log and continue; SQLite will fail later if still missing
|
||||||
|
try { logger.warn('SQLite directory ensure failed', { error: e.message }); } catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Create database connection with built-in retry logic
|
// Create database connection with built-in retry logic
|
||||||
const db = knex(knexConfig);
|
const db = knex(knexConfig);
|
||||||
|
|
||||||
@@ -312,4 +333,4 @@ async function logActivity(activityType, metadata = {}, eventId = null, actor =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { db, initializeDatabase, logActivity, withRetry };
|
module.exports = { db, initializeDatabase, logActivity, withRetry };
|
||||||
|
|||||||
@@ -569,6 +569,9 @@ setup_native_installation() {
|
|||||||
cd "$NATIVE_APP_DIR/app/backend"
|
cd "$NATIVE_APP_DIR/app/backend"
|
||||||
npm install --production
|
npm install --production
|
||||||
|
|
||||||
|
# Ensure SQLite data directory exists for native installs
|
||||||
|
mkdir -p "$NATIVE_APP_DIR/app/backend/data"
|
||||||
|
|
||||||
# Generate secrets
|
# Generate secrets
|
||||||
local jwt_secret=$(generate_jwt_secret)
|
local jwt_secret=$(generate_jwt_secret)
|
||||||
[[ -z "$ADMIN_PASSWORD" ]] && ADMIN_PASSWORD=$(generate_password)
|
[[ -z "$ADMIN_PASSWORD" ]] && ADMIN_PASSWORD=$(generate_password)
|
||||||
|
|||||||
Reference in New Issue
Block a user