前端(Vite + React)、API/worker(Fastify + BullMQ)、api-contracts 契约包、 迁移脚本、测试与自托管 docker-compose 示例。 开源准备:运维脚本与机器信息已拆到私有仓库;公司名、备案号、隐私邮箱改读 publicCompliance.local.json(仓库只保留占位模板);站点地址与客服二维码改为 VITE_ 环境变量;fixtures 中的真实用户标识已匿名化;三个 package.json 标注 Apache-2.0。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
30 lines
806 B
SQL
30 lines
806 B
SQL
ALTER TABLE users
|
|
ADD COLUMN IF NOT EXISTS auth_version integer NOT NULL DEFAULT 1;
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM pg_constraint
|
|
WHERE conname = 'users_auth_version_positive'
|
|
AND conrelid = 'users'::regclass
|
|
) THEN
|
|
ALTER TABLE users
|
|
ADD CONSTRAINT users_auth_version_positive CHECK (auth_version > 0);
|
|
END IF;
|
|
END
|
|
$$;
|
|
|
|
CREATE TABLE IF NOT EXISTS auth_rate_limit_events (
|
|
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
scope text NOT NULL,
|
|
key_hash char(64) NOT NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_auth_rate_limit_events_lookup
|
|
ON auth_rate_limit_events(scope, key_hash, created_at DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_auth_rate_limit_events_cleanup
|
|
ON auth_rate_limit_events(created_at);
|