|
1 | 1 | //! The domain tables (sc-8900, the data side), as docs/design-storage.md lays them out: organizations, projects, |
2 | 2 | //! builds, snapshots and their pages, page texts by hash, build groups read from earlier builds (the |
3 | | -//! `effective_snapshots` view), baselines, renders, diffs, blobs, reviews, comments and the credit ledger. |
| 3 | +//! `effective_snapshots` view), baselines, renders, diffs, blobs, reviews, comments, bulk downloads and the credit ledger. |
4 | 4 | //! |
5 | 5 | //! Raw SQL: the schema builder has no views, partial or BRIN indexes, or lz4 compression. `parent_commits`, |
6 | 6 | //! `shards_finalized` and `reviews.snapshot_ids` are JSON arrays, since Laravel Rust 0.1.4 has no PostgreSQL array |
@@ -1035,6 +1035,26 @@ CREATE VIEW effective_snapshots AS |
1035 | 1035 | -- A build's visualci.yml item is its own: never read from another build. |
1036 | 1036 | WHERE g.source_build_id IS NOT NULL AND s.platform <> 'visualci'; |
1037 | 1037 |
|
| 1038 | +-- Bulk downloads of a build's images (sc-8869): one tar.zst per build and filter, reused within the hour. |
| 1039 | +CREATE TABLE downloads ( |
| 1040 | + id bigserial PRIMARY KEY, |
| 1041 | + pid uuid NOT NULL UNIQUE, |
| 1042 | + build_id bigint NOT NULL REFERENCES builds(id) ON DELETE CASCADE, |
| 1043 | + filter jsonb NOT NULL, |
| 1044 | + filter_key text NOT NULL, |
| 1045 | + state text DEFAULT 'pending'::text NOT NULL, |
| 1046 | + object_key text, |
| 1047 | + files integer DEFAULT 0 NOT NULL, |
| 1048 | + bytes bigint DEFAULT 0 NOT NULL, |
| 1049 | + summary jsonb DEFAULT '{}'::jsonb NOT NULL, |
| 1050 | + error text, |
| 1051 | + ready_at timestamp with time zone, |
| 1052 | + created_at timestamp with time zone DEFAULT now() NOT NULL, |
| 1053 | + updated_at timestamp with time zone DEFAULT now() NOT NULL |
| 1054 | +); |
| 1055 | +CREATE INDEX downloads_build_filter ON downloads USING btree (build_id, filter_key, created_at DESC); |
| 1056 | +CREATE INDEX downloads_created_brin ON downloads USING brin (created_at); |
| 1057 | +
|
1038 | 1058 | -- Project tokens (the auth migration) belong to a project. |
1039 | 1059 | ALTER TABLE ONLY project_tokens |
1040 | 1060 | ADD CONSTRAINT project_tokens_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; |
|
0 commit comments