MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / createApplicationMenu

Function createApplicationMenu

main.js:2181–2367  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2179
2180 console.log('dateAdded column added and existing records updated');
2181 } else {
2182 console.log('dateAdded column already exists');
2183 }
2184
2185 return true;
2186 } catch (error) {
2187 console.error('Error migrating dateAdded column:', error);
2188 return false;
2189 }
2190}
2191
2192/** Add isNew column for "new until edited" badge; existing rows are not new. */
2193function migrateIsNewColumn() {
2194 try {
2195 console.log('Checking for isNew column migration...');
2196 const tableInfo = db.prepare('PRAGMA table_info(models)').all();
2197 const hasIsNew = tableInfo.some(col => col.name === 'isNew');
2198 if (!hasIsNew) {
2199 console.log('isNew column not found. Adding it...');
2200 db.prepare('ALTER TABLE models ADD COLUMN isNew INTEGER DEFAULT 1').run();
2201 db.prepare('UPDATE models SET isNew = 0').run();
2202 console.log('isNew column added; existing models marked as not new');
2203 } else {
2204 console.log('isNew column already exists');
2205 }
2206 return true;
2207 } catch (error) {
2208 console.error('Error migrating isNew column:', error);
2209 return false;
2210 }
2211}
2212
2213/** Add rating (0-5) and favorite (0/1) columns for model engagement. */
2214function migrateRatingFavoriteColumns() {
2215 try {
2216 console.log('Checking for rating/favorite column migration...');
2217 const tableInfo = db.prepare('PRAGMA table_info(models)').all();
2218 const hasRating = tableInfo.some(col => col.name === 'rating');
2219 const hasFavorite = tableInfo.some(col => col.name === 'favorite');
2220 if (!hasRating) {
2221 console.log('rating column not found. Adding it...');
2222 db.prepare('ALTER TABLE models ADD COLUMN rating INTEGER DEFAULT 0').run();
2223 db.prepare('UPDATE models SET rating = 0 WHERE rating IS NULL').run();
2224 }
2225 if (!hasFavorite) {
2226 console.log('favorite column not found. Adding it...');
2227 db.prepare('ALTER TABLE models ADD COLUMN favorite INTEGER DEFAULT 0').run();
2228 db.prepare('UPDATE models SET favorite = 0 WHERE favorite IS NULL').run();
2229 }
2230 return true;
2231 } catch (error) {
2232 console.error('Error migrating rating/favorite columns:', error);
2233 return false;
2234 }
2235}
2236
2237/** Zip bundle columns for grouped browsing (folder siblings are not bundled). */
2238function migrateBundleColumns() {

Callers 1

main.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected