-- Container registry (OCI Distribution). An image is a package of kind 'oci' whose name_key is -- the repository path below the owner (`app` for `tahinli/app`, `a/b` for `tahinli/a/b`). -- Blob bytes live in blob storage under `oci/`, shared by digest; the rows here say which -- package may use which digest. Manifests keep their exact bytes, so the digest stays valid. -- The blobs a package may read (layers, configs and uploads it has linked). Child manifests of an -- index are not blobs; they live in oci_manifests. `created_at` is when the package linked it. CREATE TABLE oci_blobs ( package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE, digest TEXT NOT NULL, size INTEGER NOT NULL, created_at TEXT NOT NULL, PRIMARY KEY (package_id, digest) ); CREATE INDEX oci_blobs_digest ON oci_blobs(digest); -- Manifests by digest. `content` is the manifest JSON as pushed. `size` is the total of the -- image's config and layers (the manifest's own length for an index). CREATE TABLE oci_manifests ( id TEXT PRIMARY KEY, package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE, digest TEXT NOT NULL, media_type TEXT NOT NULL, content TEXT NOT NULL, size INTEGER NOT NULL, created_at TEXT NOT NULL, UNIQUE (package_id, digest) ); -- Tags point at one manifest of their package. CREATE TABLE oci_tags ( package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE, tag TEXT NOT NULL, manifest_id TEXT NOT NULL REFERENCES oci_manifests(id) ON DELETE CASCADE, updated_at TEXT NOT NULL, PRIMARY KEY (package_id, tag) ); CREATE INDEX oci_tags_manifest ON oci_tags(manifest_id); -- What each manifest refers to: config and layer digests (blobs), or child manifest digests of an -- index. The mark step of garbage collection reads these rows. CREATE TABLE oci_manifest_refs ( manifest_id TEXT NOT NULL REFERENCES oci_manifests(id) ON DELETE CASCADE, digest TEXT NOT NULL, PRIMARY KEY (manifest_id, digest) ); CREATE INDEX oci_manifest_refs_digest ON oci_manifest_refs(digest);