phucsd commited on
Commit
62b9cee
·
1 Parent(s): 4fb27a7

fix: checkpoint full 118 Thuan Phat papers into printcal.db and auto-migrate legacy databases

Browse files
Files changed (2) hide show
  1. data/printcal.db +0 -0
  2. src/lib/db.ts +4 -1
data/printcal.db CHANGED
Binary files a/data/printcal.db and b/data/printcal.db differ
 
src/lib/db.ts CHANGED
@@ -145,7 +145,10 @@ function initSchema(db: DatabaseSync) {
145
 
146
  function seedDefaultData(db: DatabaseSync) {
147
  const paperCount = db.prepare('SELECT COUNT(*) as cnt FROM paper_types').get() as { cnt: number };
148
- if (paperCount.cnt === 0) {
 
 
 
149
  const insertPaper = db.prepare(`
150
  INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_per_ram, price_per_kg, unit, description)
151
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
 
145
 
146
  function seedDefaultData(db: DatabaseSync) {
147
  const paperCount = db.prepare('SELECT COUNT(*) as cnt FROM paper_types').get() as { cnt: number };
148
+ if (paperCount.cnt < 100) {
149
+ if (paperCount.cnt > 0) {
150
+ db.exec('DELETE FROM paper_types;');
151
+ }
152
  const insertPaper = db.prepare(`
153
  INSERT INTO paper_types (code, name, gsm, parent_width_cm, parent_height_cm, price_per_ram, price_per_kg, unit, description)
154
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)