-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset-database.html
More file actions
55 lines (45 loc) · 2.08 KB
/
reset-database.html
File metadata and controls
55 lines (45 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<title>Reset Database</title>
<script src="./node_modules/sql.js/dist/sql-wasm.js"></script>
</head>
<body>
<h1>Database Reset</h1>
<button id="resetBtn">Reset Database</button>
<button id="exportBtn" disabled>Export Database</button>
<p id="status">Click "Reset Database" to begin...</p>
<script type="module">
import { initDb, exportDb } from './src/database/initDB.js';
let db = null;
document.getElementById('resetBtn').addEventListener('click', async () => {
document.getElementById('status').textContent = 'Resetting database...';
console.log("Resetting database...");
db = await initDb();
console.log("✅ Database reset complete!");
// Verify it worked
const result = db.exec("SELECT * FROM stageTypeAllowedContexts");
console.log("Allowed contexts:", result);
document.getElementById('status').textContent = '✅ Database reset complete! You can now export it.';
document.getElementById('exportBtn').disabled = false;
// Verify LAB was added
const labResult = db.exec("SELECT ingredientTypeID, name FROM ingredientTypes WHERE name LIKE '%LAB%'");
console.log("LAB ingredient:", labResult);
const labContextResult = db.exec(`
SELECT it.name, uc.name as context
FROM ingredientTypes it
JOIN ingredientTypeContexts itc ON it.ingredientTypeID = itc.ingredientTypeID
JOIN usageContexts uc ON itc.contextID = uc.contextID
WHERE it.name LIKE '%LAB%'
`);
console.log("LAB contexts:", labContextResult);
});
document.getElementById('exportBtn').addEventListener('click', () => {
if (db) {
exportDb(db, 'brewcode.db');
document.getElementById('status').textContent = '✅ Database exported as brewcode.db!';
}
});
</script>
</body>
</html>