用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/diegosouzapw/awesome-omni-skill --skill db-migration命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Token-efficient tracking for AI orchestration. CLI-first for status updates (~50 tokens), agent fallback for complex ops (~1KB). Use when: updating task status, querying blockers, creating progress files, validating phases.
AshAi extension guidelines for integrating AI capabilities with Ash Framework. Use when implementing vectorization/embeddings, exposing Ash actions as LLM tools, creating prompt-backed actions, or setting up MCP servers. Covers semantic search, LangChain integration, and structured outputs.
This skill should be used when solving hard questions, complex architectural problems, or debugging issues that benefit from GPT-5 Pro or GPT-5.1 thinking models with large file context. Use when standard Claude analysis needs deeper reasoning or extended context windows.
正在显示 SKILL.md
基于 SOC 职业分类
| name | db-migration |
| description | Supabase migration patterns, RLS audit, schema validation. Guides safe DDL operations. |
| argument-hint | [migration-name] |
| disable-model-invocation | true |
| version | 1.1 |
Supabase migration patterns, RLS audit, schema validation. Guides safe DDL operations against the Supabase database.
| Contexte detecte | Proposition |
|---|---|
| User mentionne migration, DDL, ALTER TABLE | /db-migration [nom] |
| Modification schema Supabase ou RLS | /db-migration |
| Ajout/suppression colonne ou index | /db-migration [table_action] |
| Nouveau module avec tables propres | /db-migration create_[module]_tables |
SELECT pg_size_pretty(pg_total_relation_size('table_name'));SELECT count(*) FROM table_name;| Operation | Risque | Lock | Downtime potentiel |
|---|---|---|---|
| ADD COLUMN (nullable) | Bas | ACCESS EXCLUSIVE (instant) | 0 |
| ADD COLUMN (DEFAULT) | Moyen | ACCESS EXCLUSIVE (rewrite < PG14) | Minutes si table large |
| DROP COLUMN | Haut | ACCESS EXCLUSIVE | Perte de donnees irreversible |
| CREATE INDEX | Moyen | SHARE lock (bloque writes) | Minutes si table large |
| CREATE INDEX CONCURRENTLY | Bas | Pas de lock | 0 (mais plus lent) |
| DROP TABLE | Critique | ACCESS EXCLUSIVE | Perte complete |
| ALTER TYPE | Haut | ACCESS EXCLUSIVE (rewrite) | Minutes |
backend/supabase/migrations/YYYYMMDD_description.sqlmcp__supabase__apply_migrationmcp__supabase__list_migrationsmcp__supabase__list_tables → verifier le schemamcp__supabase__get_advisors(type: "security") → verifier RLSmcp__supabase__get_advisors(type: "performance") → verifier indexPreparer le rollback AVANT d'executer la migration :
-- Rollback: ADD COLUMN
ALTER TABLE my_table DROP COLUMN IF EXISTS new_column;
-- Rollback: DROP COLUMN (IMPOSSIBLE sans backup)
-- ⚠️ Sauvegarder les donnees AVANT :
-- CREATE TABLE _backup_my_table_col AS SELECT id, dropped_col FROM my_table;
-- Rollback: CREATE TABLE
DROP TABLE IF EXISTS my_table;
-- Rollback: CREATE INDEX
DROP INDEX IF EXISTS idx_name;
-- Rollback: ALTER TYPE
ALTER TABLE my_table ALTER COLUMN col TYPE old_type USING col::old_type;
-- Rollback: RLS policy
DROP POLICY IF EXISTS policy_name ON my_table;
Regle : Si le rollback est impossible (DROP COLUMN, DROP TABLE), exiger confirmation utilisateur avant execution.
Pour les tables > 100K rows, utiliser le batching :
-- Backfill par batch de 10K rows
DO $$
DECLARE
batch_size INT := 10000;
total_updated INT := 0;
rows_affected INT;
BEGIN
LOOP
UPDATE my_table
SET new_column = compute_value(old_column)
WHERE new_column IS NULL
LIMIT batch_size;
GET DIAGNOSTICS rows_affected = ROW_COUNT;
total_updated := total_updated + rows_affected;
RAISE NOTICE 'Updated % rows (total: %)', rows_affected, total_updated;
EXIT WHEN rows_affected = 0;
PERFORM pg_sleep(0.1); -- Pause pour ne pas saturer
END LOOP;
END $$;
Index sur tables larges : toujours utiliser CONCURRENTLY :
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_name ON my_table (column);
Executer AVANT et APRES la migration :
-- Row counts
SELECT count(*) AS row_count FROM my_table;
-- Null check sur nouvelle colonne
SELECT count(*) FILTER (WHERE new_col IS NULL) AS nulls,
count(*) FILTER (WHERE new_col IS NOT NULL) AS filled
FROM my_table;
-- Constraint check
SELECT conname, contype FROM pg_constraint WHERE conrelid = 'my_table'::regclass;
-- Index check
SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'my_table';
-- RLS check
SELECT polname, polcmd, polroles FROM pg_policy WHERE polrelid = 'my_table'::regclass;
backend/supabase/migrations/YYYYMMDD_description.sqlmcp__supabase__execute_sql)mcp__supabase__get_advisors for security + performance-- Always use IF NOT EXISTS / IF EXISTS
CREATE TABLE IF NOT EXISTS my_table (...);
CREATE INDEX IF NOT EXISTS idx_name ON my_table (column);
DROP TABLE IF EXISTS old_table;
-- Wrap multi-statement migrations
BEGIN;
ALTER TABLE my_table ADD COLUMN new_col TEXT;
CREATE INDEX idx_new ON my_table (new_col);
COMMIT;
-- Add comments explaining purpose
COMMENT ON TABLE my_table IS 'Description of table purpose';
ALTER TABLE my_table ENABLE ROW LEVEL SECURITY;service_role key (bypasses RLS)anon key (subject to RLS)| Tool | Use |
|---|---|
mcp__supabase__apply_migration | DDL operations (CREATE, ALTER, DROP) |
mcp__supabase__execute_sql | DML/queries (SELECT, INSERT, UPDATE) |
mcp__supabase__list_tables | Verify schema after changes |
mcp__supabase__get_advisors | Security + performance check |
mcp__supabase__list_migrations | Check existing migrations |
DROP TABLE without backup/confirmationALTER TABLE with data loss potential (dropping columns with data)execute_sql (use apply_migration for audit trail)IF NOT EXISTS on CREATE statements## Migration Report — [nom_migration]
### Phase 1 — Analyse
- Table(s) cible : [liste]
- Taille : [size] / [row_count] rows
- Operation : [type]
- Risque : Bas / Moyen / Haut / Critique
### Phase 2 — Plan
- SQL migration : [resume]
- SQL rollback : [resume]
- Validations preparees : [N] queries
### Phase 3 — Execution
- Migration appliquee : OUI/NON
- Version : [timestamp]
### Phase 4 — Verification
| Check | Status |
|-------|--------|
| Schema correct | PASS/FAIL |
| RLS advisors | PASS/FAIL |
| Performance advisors | PASS/FAIL |
| Queries applicatives | PASS/FAIL |
| Skill | Direction | Declencheur |
|---|---|---|
rag-ops | ← recoit | Modifications schema __rag_knowledge, kg_rag_* |
seo-content-architect | ← recoit | Modifications schema __seo_*, pieces_gamme |
code-review | ← recoit | /code-review detecte des fichiers .sql dans le diff |