max: {
major: 1,
minor: 0,
- patch: 0,
+ patch: 1,
},
};
SELECT *
FROM verification
WHERE
- (topic_id, callback, created) IN (SELECT topic_id, callback, max(created) AS created FROM verification GROUP BY (topic_id, callback))
+ (topic_id, callback, created) IN (SELECT topic_id, callback, max(created) AS created FROM verification GROUP BY topic_id, callback)
AND
(topic_id, callback) NOT IN (SELECT topic_id, callback FROM verification_in_progress_active)
AND
--- /dev/null
+BEGIN;
+ -- Ignore verifications with topics which are not yet active.
+ CREATE OR REPLACE VIEW verification_needed AS
+ SELECT v.*
+ FROM verification v JOIN topic t ON v.topic_id = t.id
+ WHERE
+ t.is_active
+ AND
+ (v.topic_id, v.callback, v.created) IN (SELECT topic_id, callback, max(created) AS created FROM verification GROUP BY topic_id, callback)
+ AND
+ (v.topic_id, v.callback) NOT IN (SELECT topic_id, callback FROM verification_in_progress_active)
+ AND
+ v.next_attempt <= now()
+ ;
+
+ INSERT INTO _meta_schema_version (major, minor, patch) VALUES (1, 0, 1);
+COMMIT;
+
--- /dev/null
+BEGIN;
+ CREATE OR REPLACE VIEW verification_needed AS
+ SELECT *
+ FROM verification
+ WHERE
+ (topic_id, callback, created) IN (SELECT topic_id, callback, max(created) AS created FROM verification GROUP BY topic_id, callback)
+ AND
+ (topic_id, callback) NOT IN (SELECT topic_id, callback FROM verification_in_progress_active)
+ AND
+ next_attempt <= now()
+ ;
+
+ DELETE FROM _meta_schema_version WHERE major = 1 AND minor = 0 AND patch = 1;
+COMMIT;
+
max: {
major: 1,
minor: 0,
- patch: 0,
+ patch: 1,
},
};
--- /dev/null
+BEGIN;
+ DROP VIEW verification_needed;
+ CREATE VIEW verification_needed AS
+ SELECT v.*
+ FROM verification v JOIN topic t ON v.topic_id = t.id
+ WHERE
+ t.is_active
+ AND
+ (v.topic_id, v.callback, v.created) IN (SELECT topic_id, callback, max(created) AS created FROM verification GROUP BY topic_id, callback)
+ AND
+ (v.topic_id, v.callback) NOT IN (SELECT topic_id, callback FROM verification_in_progress_active)
+ AND
+ v.next_attempt <= (strftime('%s', 'now'))
+ ;
+
+ INSERT INTO _meta_schema_version (major, minor, patch) VALUES (1, 0, 1);
+COMMIT;
+
--- /dev/null
+BEGIN;
+ DROP VIEW verification_needed;
+ CREATE VIEW verification_needed AS
+ SELECT *
+ FROM verification
+ WHERE
+ (topic_id, callback, created) IN (SELECT topic_id, callback, max(created) AS created FROM verification GROUP BY topic_id, callback)
+ AND
+ (topic_id, callback) NOT IN (SELECT topic_id, callback FROM verification_in_progress_active)
+ AND
+ next_attempt <= (strftime('%s', 'now'))
+ ;
+
+ DELETE FROM _meta_schema_version WHERE major = 1 AND minor = 0 AND patch = 1;
+COMMIT;
+