ce8026d46e
- serialise publishes per crate with an advisory lock in one transaction - add a unique index on normalised name and version without build metadata - validate versions as strict SemVer 2.0 and reject an empty .crate - renumber the migration to 0005
20 lines
830 B
SQL
20 lines
830 B
SQL
-- Local cargo registries: one sparse-index line per published crate version.
|
|
-- line holds the index JSON minus yanked, which flips on yank/unyank.
|
|
CREATE TABLE IF NOT EXISTS cargo_index (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
repo_name TEXT NOT NULL,
|
|
file_path TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
version TEXT NOT NULL,
|
|
line TEXT NOT NULL,
|
|
yanked BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
UNIQUE(repo_name, file_path)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_cargo_index_repo_name ON cargo_index(repo_name, lower(name));
|
|
|
|
-- Cargo treats names equal up to case and -/_, and versions equal up to build metadata.
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_cargo_index_unique_version
|
|
ON cargo_index(repo_name, replace(lower(name), '-', '_'), split_part(version, '+', 1));
|