24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* release_final() with the release's complete flag: a release with every file its counter announced is final as it is
|
|
* (nothing it lacks can come); the time window only decides for the incomplete and those without a counter (LOG.md
|
|
* 2026-10-16 (70): a complete episode posted an hour before was "pending" for six hours more).
|
|
*/
|
|
export default class extends BaseSchema {
|
|
async up() {
|
|
// Beside the five-argument one, which the services still running call until the deploy restarts them.
|
|
this.schema.raw(`
|
|
CREATE FUNCTION release_final(g integer, first_article bigint, last_article bigint, posted timestamptz, last_posted timestamptz, complete boolean)
|
|
RETURNS boolean LANGUAGE sql STABLE AS $$
|
|
SELECT coalesce(complete, false) OR EXISTS (
|
|
SELECT 1 FROM range_blocks b
|
|
WHERE b.group_id = g AND b.start_id <= first_article AND b.end_id >= last_article
|
|
AND (b.at_group_start OR b.posted_low <= posted - interval '6 hours')
|
|
AND b.posted_high >= coalesce(last_posted, posted) + interval '6 hours')
|
|
$$`)
|
|
}
|
|
|
|
async down() {}
|
|
}
|