Skip to content

Commit 5ad059f

Browse files
author
Lasim
committed
Refactor database configuration to support SQLite only
- Updated drizzle.config.ts to remove PostgreSQL support and default to SQLite configuration. - Removed PostgreSQL migration files and related schemas. - Simplified database connection logic in db/index.ts and related files to focus solely on SQLite. - Adjusted frontend setup forms and validation to reflect the removal of PostgreSQL options. - Cleaned up Lucia authentication integration to work exclusively with SQLite. - Updated error handling and logging for database operations to align with the new SQLite-only approach.
1 parent 30291cc commit 5ad059f

File tree

17 files changed

+186
-525
lines changed

17 files changed

+186
-525
lines changed

package-lock.json

Lines changed: 48 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/backend/drizzle.config.ts

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,43 @@ import fs from 'fs';
33
import path from 'path';
44

55
interface DbSelection {
6-
type: 'sqlite' | 'postgres';
7-
dbPath?: string; // For sqlite
8-
connectionString?: string; // For postgres
6+
type: 'sqlite';
7+
dbPath: string;
98
}
109

1110
// Function to read config (simplified, synchronous for CLI tool)
1211
function getDbSelectionConfig(): DbSelection | null {
13-
// Assumes drizzle.config.ts is in services/backend/
14-
const configPath = path.resolve(__dirname, './data/db.selection.json');
12+
// Updated path to match the actual location used by the application
13+
const configPath = path.resolve(__dirname, './persistent_data/db.selection.json');
1514
try {
1615
if (fs.existsSync(configPath)) {
1716
const raw = fs.readFileSync(configPath, 'utf-8');
1817
return JSON.parse(raw) as DbSelection;
1918
}
20-
console.log("db.selection.json not found, defaulting to SQLite for drizzle-kit.");
19+
console.log("db.selection.json not found, using default SQLite configuration for drizzle-kit.");
2120
} catch (e) {
22-
console.error("Error reading db.selection.json for drizzle-kit, defaulting to SQLite:", e);
21+
console.error("Error reading db.selection.json for drizzle-kit, using default SQLite configuration:", e);
2322
}
2423
return null; // Default to SQLite if no config or error
2524
}
2625

2726
const dbSelection = getDbSelectionConfig();
2827

29-
let drizzleKitConfig: Config;
28+
// Default SQLite configuration
29+
const sqliteDbPath = (dbSelection?.dbPath)
30+
? dbSelection.dbPath
31+
: 'persistent_data/database/deploystack.db'; // Default SQLite path
3032

31-
if (dbSelection && dbSelection.type === 'postgres' && dbSelection.connectionString) {
32-
console.log("[INFO] drizzle.config.ts: Using PostgreSQL dialect for drizzle-kit.");
33-
drizzleKitConfig = {
34-
dialect: "postgresql",
35-
schema: "./src/db/schema.pg.ts", // Point to PG-specific schema for drizzle-kit
36-
out: "./drizzle/migrations_pg", // PostgreSQL specific migrations
37-
dbCredentials: {
38-
url: dbSelection.connectionString, // drizzle-kit uses 'url' for PG connection string
39-
},
40-
};
41-
} else {
42-
// Default to SQLite if no config, error, or SQLite selected
43-
const sqliteDbPath = (dbSelection?.type === 'sqlite' && dbSelection.dbPath)
44-
? dbSelection.dbPath
45-
: './data/deploystack.db'; // Default SQLite path
33+
console.log(`[INFO] drizzle.config.ts: Using SQLite dialect for drizzle-kit. DB path: ${sqliteDbPath}`);
4634

47-
// Ensure the path used by drizzle-kit for SQLite is relative to `services/backend`
48-
// If dbPath from config is like "data/deploystack.db", it's already correct.
49-
// If it's absolute, drizzle-kit might handle it, but relative is safer.
50-
// For SQLite, `url` should be the file path.
51-
console.log(`[INFO] drizzle.config.ts: Using SQLite dialect for drizzle-kit. DB path: ${sqliteDbPath}`);
52-
drizzleKitConfig = {
53-
dialect: "sqlite",
54-
schema: "./src/db/schema.sqlite.ts", // Point to SQLite-specific schema for drizzle-kit
55-
out: "./drizzle/migrations_sqlite", // SQLite specific migrations
56-
dbCredentials: {
57-
url: path.isAbsolute(sqliteDbPath) ? sqliteDbPath : path.resolve(__dirname, sqliteDbPath),
58-
},
59-
};
60-
}
35+
const drizzleKitConfig: Config = {
36+
dialect: "sqlite",
37+
schema: "./src/db/schema.sqlite.ts", // Point to SQLite-specific schema for drizzle-kit
38+
out: "./drizzle/migrations_sqlite", // SQLite specific migrations
39+
dbCredentials: {
40+
url: path.isAbsolute(sqliteDbPath) ? sqliteDbPath : path.resolve(__dirname, sqliteDbPath),
41+
},
42+
};
6143

6244
export default defineConfig({
6345
...drizzleKitConfig,

services/backend/drizzle/migrations/0000_classy_metal_master.sql

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)