user_profile sqlite3 cleanup
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
6578d3c856
commit
4e8127b5c8
@ -45,7 +45,9 @@ const USER_PROFILE_DB_PATH = path.join(ROOT_DIR, 'user_profile.db');
|
|||||||
const DB_POOL_SIZE = 6;
|
const DB_POOL_SIZE = 6;
|
||||||
const API_BASE = (process.env.APTIVA_INTERNAL_API || 'http://server1:5000').replace(/\/+$/, '');
|
const API_BASE = (process.env.APTIVA_INTERNAL_API || 'http://server1:5000').replace(/\/+$/, '');
|
||||||
|
|
||||||
for (const p of [CIP_TO_SOC_PATH, INSTITUTION_DATA_PATH, SALARY_DB_PATH, USER_PROFILE_DB_PATH]) {
|
const REQUIRED_FILES = [CIP_TO_SOC_PATH, INSTITUTION_DATA_PATH, SALARY_DB_PATH];
|
||||||
|
if (process.env.NODE_ENV !== 'production') REQUIRED_FILES.push(USER_PROFILE_DB_PATH);
|
||||||
|
for (const p of REQUIRED_FILES) {
|
||||||
if (!fs.existsSync(p)) {
|
if (!fs.existsSync(p)) {
|
||||||
console.error(`FATAL Required data file not found → ${p}`);
|
console.error(`FATAL Required data file not found → ${p}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@ -535,17 +537,18 @@ async function initDatabases() {
|
|||||||
AND (AREA_TITLE = ? OR AREA_TITLE = 'U.S.')
|
AND (AREA_TITLE = ? OR AREA_TITLE = 'U.S.')
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// In prod, user_profile is MySQL; do not try to open a SQLite file here.
|
// In prod, user_profile is MySQL; do not open a SQLite file.
|
||||||
// Leave dev behavior untouched: only open SQLite if clearly running non-prod.
|
// Allow opt-in via USE_SQLITE_USER_PROFILE=1 for dev/local only.
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.USE_SQLITE_USER_PROFILE === '1') {
|
||||||
userProfileDb = await open({
|
userProfileDb = await open({
|
||||||
filename: USER_PROFILE_DB_PATH,
|
filename: `file:${USER_PROFILE_DB_PATH}?mode=ro`,
|
||||||
driver : sqlite3.Database
|
driver : sqlite3.Database,
|
||||||
|
mode : sqlite3.OPEN_READONLY | sqlite3.OPEN_URI
|
||||||
});
|
});
|
||||||
console.log('✅ Connected to user_profile.db (sqlite, dev)');
|
console.log('✅ Connected to user_profile.db (sqlite, ro)');
|
||||||
} else {
|
} else {
|
||||||
userProfileDb = null;
|
userProfileDb = null;
|
||||||
console.log('ℹ️ user_profile via MySQL pool (no SQLite open in prod)');
|
console.log('ℹ️ user_profile via MySQL pool (SQLite disabled)');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('❌ DB init failed →', err);
|
console.error('❌ DB init failed →', err);
|
||||||
|
Loading…
Reference in New Issue
Block a user