Browse Source

add some indexes and change some column names

pull/1/head
Trent Larson 7 months ago
parent
commit
67a207fad6
  1. 2
      server.js
  2. 9
      sql/migrations/V1__Create_image_table.sql

2
server.js

@ -85,7 +85,7 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => {
const currentDate = new Date().toISOString(); const currentDate = new Date().toISOString();
const localFile = req.file.path.startsWith(uploadDir + '/') ? req.file.path.substring(uploadDir.length + 1) : req.file.path; 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}`; 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, currentDate,
issuerDid, issuerDid,
localFile, localFile,

9
sql/migrations/V1__Create_image_table.sql

@ -1,8 +1,13 @@
CREATE TABLE image ( CREATE TABLE image (
date TEXT NOT NULL, time TEXT NOT NULL,
did TEXT NOT NULL, did TEXT NOT NULL,
local_file TEXT NOT NULL, local_file TEXT NOT NULL,
size INTEGER NOT NULL, size INTEGER NOT NULL,
aws_file TEXT NOT NULL, final_file TEXT NOT NULL,
url 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);

Loading…
Cancel
Save