From 67a207fad63785509e10f575c7adbca029791fe7 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 3 Mar 2024 12:46:45 -0700 Subject: [PATCH] add some indexes and change some column names --- server.js | 2 +- sql/migrations/V1__Create_image_table.sql | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 80c6266..3c4d41b 100644 --- a/server.js +++ b/server.js @@ -85,7 +85,7 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => { const currentDate = new Date().toISOString(); const localFile = req.file.path.startsWith(uploadDir + '/') ? req.file.path.substring(uploadDir.length + 1) : req.file.path; const finalUrl = `https://${bucketName}.s3.amazonaws.com/${fileName}`; - await db.run('INSERT INTO image (date, did, local_file, size, aws_file, url) VALUES (?, ?, ?, ?, ?, ?)', [ + await db.run('INSERT INTO image (time, did, local_file, size, final_file, url) VALUES (?, ?, ?, ?, ?, ?)', [ currentDate, issuerDid, localFile, diff --git a/sql/migrations/V1__Create_image_table.sql b/sql/migrations/V1__Create_image_table.sql index fe420ec..fdf5470 100644 --- a/sql/migrations/V1__Create_image_table.sql +++ b/sql/migrations/V1__Create_image_table.sql @@ -1,8 +1,13 @@ + CREATE TABLE image ( - date TEXT NOT NULL, + time TEXT NOT NULL, did TEXT NOT NULL, local_file TEXT NOT NULL, size INTEGER NOT NULL, - aws_file TEXT NOT NULL, + final_file TEXT NOT NULL, url TEXT NOT NULL ); + +CREATE INDEX image_date ON image(time); +CREATE INDEX image_did ON image(did); +CREATE INDEX image_finalFile ON image(final_file);