Rebuild: schema for groups, rule sets, ranges, release catalog, chunk store, fragments, probe queue, rule bookkeeping and nodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a18ead666b
commit
2209921846
11 files changed
+1228
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
/**
|
||||
* The release catalog (REBUILD.md, part 4): one row per release, the hot
|
||||
* part on fast disk. Updated with aggregates once per batch; the files
|
||||
* themselves are in release_chunks.
|
||||
*/
|
||||
export default class extends BaseSchema {
|
||||
async up() {
|
||||
this.schema.createTable('releases', (table) => {
|
||||
table.bigIncrements('id')
|
||||
table.string('release_key', 40).notNullable().unique()
|
||||
table.text('name').notNullable()
|
||||
table.string('source', 16).notNullable()
|
||||
table.text('poster').nullable()
|
||||
table.jsonb('groups').notNullable()
|
||||
table.timestamp('posted_at', { useTz: true }).nullable()
|
||||
// Files announced by the [i/N] counter, when present.
|
||||
table.integer('file_total').nullable()
|
||||
table.integer('files').notNullable().defaultTo(0)
|
||||
table.bigInteger('segments').notNullable().defaultTo(0)
|
||||
table.bigInteger('bytes').notNullable().defaultTo(0)
|
||||
table.integer('chunks').notNullable().defaultTo(0)
|
||||
table.bigInteger('first_article').nullable()
|
||||
table.bigInteger('last_article').nullable()
|
||||
table.boolean('readable').notNullable().defaultTo(false)
|
||||
table.boolean('has_par2').notNullable().defaultTo(false)
|
||||
table.boolean('complete').nullable()
|
||||
table.timestamp('settled_at', { useTz: true }).nullable()
|
||||
table.timestamp('first_seen_at', { useTz: true }).notNullable().defaultTo(this.now())
|
||||
table.timestamp('last_seen_at', { useTz: true }).notNullable().defaultTo(this.now())
|
||||
})
|
||||
this.schema.raw(`CREATE EXTENSION IF NOT EXISTS pg_trgm`)
|
||||
this.schema.raw(`CREATE INDEX releases_name_trgm ON releases USING gin (name gin_trgm_ops)`)
|
||||
this.schema.raw(`CREATE INDEX releases_posted_at_idx ON releases (posted_at DESC)`)
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable('releases')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user