数据库架构迁移
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 数据
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Database Schema Migrations
Manage schema design, migrations, and database operations.
## Key Responsibilities
- Design and version schema changes.
- Write migration scripts.
- Ensure database compatibility.
- Provide rollback-safe migration steps.
## Migration Pattern
```sql
-- Good: Idempotent migration
CREATE TABLE IF NOT EXISTS resources (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
owner_id TEXT NOT NULL,
created_at INTEGER DEFAULT (unixepoch())
);
-- Good: Safe index addition
CREATE INDEX IF NOT EXISTS idx_resources_owner ON resources(owner_id);
```
## Naming Convention
- Migration files: `YYYYMMDD_description.sql`
- Tables: snake_case, plural (e.g., `resources`, `permissions`)
- Columns: snake_case (e.g., `resource_id`, `created_at`)
## Constraints
- Migrations must be idempotent and reversible.
- Indexes must be added in a way that doesn't break existing queries.
- Use timestamp-prefixed filenames.
- Always provide rollback scripts.
## Checklist
- [ ] Migration is idempotent (can run multiple times safely).
- [ ] Rollback migration tested.
- [ ] Indexes use `IF NOT EXISTS`.
- [ ] Foreign keys defined where applicable.
- [ ] Migration logged in migration history table.
## References
- `references/migration-patterns.md` - Common migration patterns by database type
- `references/rollback-strategies.md` - Safe rollback strategies
---
> Source: [d-o-hub/github-template-ai-agents](https://github.com/d-o-hub/github-template-ai-agents) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
主要职责
命名约定
约束条件
清单
参考文献
文件/命令 -> YYYYMMDD_description.sql · resources · permissions · resource_id · created_at · IF NOT EXISTS · references/migration-patterns.md · references/rollback-strategies.md
内容校验值 -> 06d19f972789
当前原文的自动摘译,尚未人工审校。
主要职责
设计和版本架构更改。编写迁移脚本。确保数据库兼容性。提供回滚安全的迁移步骤。
命名约定
迁移文件:
YYYYMMDD_description.sql表:snake_case,复数(例如,resources、permissions) 列:snake_case(例如,resource_id、created_at)约束条件
迁移必须是幂等且可逆的。添加索引的方式必须不会破坏现有查询。使用时间戳前缀的文件名。始终提供回滚脚本。
清单
[ ] 迁移是幂等的(可以安全地运行多次)。 [ ] 回滚迁移已测试。 [ ] 索引使用
IF NOT EXISTS。 [ ] 定义适用的外键。 [ ] 迁移记录在迁移历史表中。参考文献
references/migration-patterns.md- 按数据库类型划分的常见迁移模式references/rollback-strategies.md- 安全回滚策略 来源:d-o-hub/github-template-ai-agents — 由 TomeVault 分发。