-- Package registries: the packages an owner (user or org) publishes, and their versions. `kind` -- names the registry format ('cargo' now; a container registry would add 'oci' rows beside them). -- `name_key` is the lowercase name that the index and the URLs use; `name` keeps the spelling of -- the first publish. The .crate bytes live in blob storage under `packages/`; a -- version row keeps the checksum, the index line and the README text. `repo_id` links a package -- to a repo on this forge, found from the crate's `repository` field. CREATE TABLE packages ( id TEXT PRIMARY KEY, owner_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, kind TEXT NOT NULL, name TEXT NOT NULL, name_key TEXT NOT NULL, repo_id TEXT REFERENCES repos(id) ON DELETE SET NULL, private INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, UNIQUE (owner_id, kind, name_key) ); CREATE INDEX packages_repo ON packages(repo_id); CREATE TABLE package_versions ( id TEXT PRIMARY KEY, package_id TEXT NOT NULL REFERENCES packages(id) ON DELETE CASCADE, version TEXT NOT NULL, yanked INTEGER NOT NULL DEFAULT 0, checksum TEXT NOT NULL, size INTEGER NOT NULL, index_json TEXT NOT NULL, description TEXT, readme TEXT, publisher_id TEXT NOT NULL REFERENCES users(id), created_at TEXT NOT NULL, UNIQUE (package_id, version) );