CREATE TABLE IF NOT EXISTS python_mirrors ( id TEXT PRIMARY KEY NOT NULL, name TEXT NOT NULL, index_url TEXT NOT NULL, trusted_host TEXT, enabled INTEGER NOT NULL DEFAULT 1 CHECK (enabled IN (0, 1)), is_default INTEGER NOT NULL DEFAULT 0 CHECK (is_default IN (0, 1)), created_at TEXT NOT NULL, updated_at TEXT NOT NULL ); -- 同一时间只允许一个默认镜像 CREATE UNIQUE INDEX IF NOT EXISTS idx_python_mirrors_default ON python_mirrors(is_default) WHERE is_default = 1; CREATE UNIQUE INDEX IF NOT EXISTS idx_python_mirrors_index_url ON python_mirrors(index_url); INSERT OR IGNORE INTO python_mirrors (id, name, index_url, trusted_host, enabled, is_default, created_at, updated_at) VALUES ( 'tsinghua', '清华 TUNA', 'https://pypi.tuna.tsinghua.edu.cn/simple', NULL, 1, 1, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now') ), ( 'aliyun', '阿里云', 'https://mirrors.aliyun.com/pypi/simple/', NULL, 1, 0, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now') ), ( 'ustc', '中科大', 'https://pypi.mirrors.ustc.edu.cn/simple/', NULL, 1, 0, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now') ), ( 'pypi', 'PyPI 官方', 'https://pypi.org/simple', NULL, 1, 0, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now') );