用途:在本地开发 dbt 模型时,防止意外写入生产 schema。做法是临时把模型写入 test schema。
主要能力与用法:
- 首次环境准备:从 pyproject.toml 安装依赖,命令为 uv pip install --requirement pyproject.toml。
- 在目标模型的 config 中加入 schema='test',建议放在最前面以减少逗号差异。
- 验证:用 uv run dbt compile --select <model_name> --profiles-dir ~/.dbt --no-use-colors 编译,确认输出包含 test schema。
- 运行:执行 dbt run 前必须获得用户许可,并确认输出 schema 为 test,命令为 uv run dbt run --select <model_name> --profiles-dir ~/.dbt --no-use-colors。
- 测试:uv run dbt test --select <model_name> --profiles-dir ~/.dbt --no-use-colors。
- 提交前:移除 schema='test',并用 git diff 确认已移除。
限制与注意:绝不能在提交时保留 schema='test';绝不能在未加 schema='test' 时运行 dbt run,否则有生产写入风险。资料未提供其他平台、收费或效果信息。