فهرست منبع

save preview to db

Pi 3 ماه پیش
والد
کامیت
2f244df1a8
3فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 3 2
      util-sqlpage/goto/save.sql
  2. 1 0
      util-sqlpage/sqlpage/migrations/009_goto.sql
  3. 1 0
      util-sqlpage/sqlpage/validate.sql

+ 3 - 2
util-sqlpage/goto/save.sql

@@ -1,8 +1,9 @@
-INSERT INTO goto (hash, content, qr, created) VALUES ($hash, $content, $qr, CURRENT_TIMESTAMP)
+INSERT INTO goto (hash, content, qr, preview, created) VALUES (:hash, :content, :qr, json(:preview), CURRENT_TIMESTAMP)
 ON CONFLICT DO
 UPDATE SET
   content = excluded.content,
   created = excluded.created,
-  qr = excluded.qr
+  qr = excluded.qr,
+  preview = excluded.preview
 WHERE excluded.created > goto.created;
 SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/link.sql') AS properties;

+ 1 - 0
util-sqlpage/sqlpage/migrations/009_goto.sql

@@ -0,0 +1 @@
+ALTER TABLE goto ADD COLUMN preview JSON;

+ 1 - 0
util-sqlpage/sqlpage/validate.sql

@@ -26,6 +26,7 @@ SET ":qr" = (
   WHERE hash = :hash AND :tool = 'upload'
 );
 
+SET ":preview" = (SELECT preview FROM goto WHERE hash = :hash AND :tool = 'goto');
 SET ":file_name" = (SELECT name FROM upload WHERE hash = :hash AND :tool = 'upload');
 SET ":mime_type" = (SELECT mime FROM upload WHERE hash = :hash AND :tool = 'upload');