forge
Explore
Log in

Don't you dare go Hollow

forge

Clone
★ 0

0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits

0062_oci.sql47 lines, 2.1 KiBHistoryRawDownload
1-- Container registry (OCI Distribution). An image is a package of kind 'oci' whose name_key is
2-- the repository path below the owner (`app` for `tahinli/app`, `a/b` for `tahinli/a/b`).
3-- Blob bytes live in blob storage under `oci/<hex>`, shared by digest; the rows here say which
4-- package may use which digest. Manifests keep their exact bytes, so the digest stays valid.
5
6-- The blobs a package may read (layers, configs and uploads it has linked). Child manifests of an
7-- index are not blobs; they live in oci_manifests. `created_at` is when the package linked it.
8CREATE TABLE oci_blobs (
9 package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE,
10 digest TEXT NOT NULL,
11 size INTEGER NOT NULL,
12 created_at TEXT NOT NULL,
13 PRIMARY KEY (package_id, digest)
14);
15CREATE INDEX oci_blobs_digest ON oci_blobs(digest);
16
17-- Manifests by digest. `content` is the manifest JSON as pushed. `size` is the total of the
18-- image's config and layers (the manifest's own length for an index).
19CREATE TABLE oci_manifests (
20 id TEXT PRIMARY KEY,
21 package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE,
22 digest TEXT NOT NULL,
23 media_type TEXT NOT NULL,
24 content TEXT NOT NULL,
25 size INTEGER NOT NULL,
26 created_at TEXT NOT NULL,
27 UNIQUE (package_id, digest)
28);
29
30-- Tags point at one manifest of their package.
31CREATE TABLE oci_tags (
32 package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE,
33 tag TEXT NOT NULL,
34 manifest_id TEXT NOT NULL REFERENCES oci_manifests(id) ON DELETE CASCADE,
35 updated_at TEXT NOT NULL,
36 PRIMARY KEY (package_id, tag)
37);
38CREATE INDEX oci_tags_manifest ON oci_tags(manifest_id);
39
40-- What each manifest refers to: config and layer digests (blobs), or child manifest digests of an
41-- index. The mark step of garbage collection reads these rows.
42CREATE TABLE oci_manifest_refs (
43 manifest_id TEXT NOT NULL REFERENCES oci_manifests(id) ON DELETE CASCADE,
44 digest TEXT NOT NULL,
45 PRIMARY KEY (manifest_id, digest)
46);
47CREATE INDEX oci_manifest_refs_digest ON oci_manifest_refs(digest);