strong_migrations
4,463
Stars
202
Forks
26
Watchers
5
Open Issues
MIT
许可证
Ruby
语言
2015-11-23
创建时间
2026-11-02
最近更新
项目能做什么
在开发阶段检测并拦截不安全的数据库迁移操作(Rails)。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Strong Migrations
Catch unsafe migrations in development
✓ Detects potentially dangerous operations<br /> ✓ Prevents them from running by default<br /> ✓ Provides instructions on safer ways to do what you want
Supports PostgreSQL, MySQL, and MariaDB
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
[](https://github.com/ankane/strong_migrations/actions)
## Installation
Add this line to your application’s Gemfile:
```ruby
gem "strong_migrations"
```
And run:
```sh
bundle install
rails generate strong_migrations:install
```
Strong Migrations sets a long statement timeout for migrations so you can set a [short statement timeout](#app-timeouts) for your application.
## How It Works
When you run a migration that’s potentially dangerous, you’ll see an error message like:
```txt
=== Dangerous operation detected #strong_migrations ===
Active Record caches attributes, which causes problems
when removing columns. Be sure to ignore the column:
class User < ApplicationRecord
self.ignored_columns += ["name"]
end
Deploy the code, then wrap this step in a safety_assured { ... } block.
class RemoveColumn < ActiveRecord::Migration[8.1]
def change
safety_assured { remove_column :users, :name }
end
end
```
An operation is classified as dangerous if it either:
- Blocks reads or writes for more than a few seconds (after a lock is acquired)
- Has a good chance of causing application errors
## Checks
Potentially dangerous operations:
- [removing a column](#removing-a-column)
- [changing the type of a column](#changing-the-type-of-a-column)
- [renaming a column](#renaming-a-column)
- [renaming a table](#renaming-a-table)
- [creating a table with the force option](#creating-a-table-with-the-force-option)
- [adding an auto-incrementing column](#adding-an-auto-incrementing-column)
- [adding a stored generated column](#adding-a-stored-generated-column)
- [adding a foreign key](#adding-a-foreign-key)
- [adding a check constraint](#adding-a-check-constraint)
- [executing SQL directly](#executing-SQL-directly)
- [backfilling data](#backfilling-data)
Postgres-specific checks:
- [adding an index non-concurrently](#adding-an-index-non-concurrently)
- [adding a reference](#adding-a-reference)
- [adding a unique constraint](#adding-a-unique-constraint)
- [adding an exclusion constraint](#adding-an-exclusion-constraint)
- [adding a json column](#adding-a-json-column)
- [adding a column with a volatile default value](#adding-a-column-with-a-volatile-default-value)
- [setting NOT NULL on an existing column](#setting-not-null-on-an-existing-column)
- [renaming an enum value](#renaming-an-enum-value)
- [renaming a schema](#renaming-a-schema)
MySQL and MariaDB-specific checks:
- [using the COPY algorithm](#using-the-copy-algorithm)
- [using shared or exclusiv
阅读完整原文
商业机会分析 AI 生成
GitHub/GitLab PR 自动化数据库迁移审查 Bot (SaaS)
| 产品构想 | 将 strong_migrations 的静态与动态规则封装为 CI/CD 服务或 GitHub App,在开发者提交包含 migration 的 PR 时自动分析安全隐患并给出修复建议。 |
| 核心功能 | PR 自动分析与注释、锁表风险等级评估、分步发布操作指南生成、团队级自定义阻断策略配置 |
| 目标用户 | 中小型 Rails 研发团队、工程效能负责人 |
| 难度/周期 | 中等 · 1 - 2 个月 · 成本:低于 $50/月(基础云函数/轻量服务器 + GitHub API) |
| 收费模式 | 按代码仓库数或开发者席位收取月费/年费(免费版限个人仓库,团队版付费) |
| 竞争风险 | 开源 Gem 本身可在本地运行阻断,单纯做 CI 检查工具壁垒较低;竞品包括已有的通用数据库 CI 工具(如 Bytebase/Atlas)。 |
| 依据 | 数据支持的判断 |
多语言通用数据库安全迁移 Linter CLI (开源核心 + 付费企业版)
| 产品构想 | 超越 Rails 生态,将 strong_migrations 沉淀的 Postgres/MySQL 安全锁表规则抽取为支持 Prisma、TypeORM、Django、Alembic 等多框架的独立 CLI 工具。 |
| 核心功能 | 抽象语法树分析与 SQL 变更解析、针对 PG/MySQL 的零停机迁移规则引擎、生成兼容当前框架的分步迁移方案代码 |
| 目标用户 | 全栈团队、跨语言技术栈架构师、平台工程团队 |
| 难度/周期 | 高 · 3 - 5 个月 · 成本:低于 $100/月(主要为开发测试数据库实例费用) |
| 收费模式 | 核心 CLI 开源,企业版提供私有规则定制、SSO、合规审计报告输出(Open-core 模式) |
| 竞争风险 | 需深入理解不同 ORM 的底层迁移行为,工程复杂度高,且跨生态获客难度增加。 |
| 依据 | AI推测 |
企业级零停机迁移咨询与定制化架构保障服务
| 产品构想 | 基于高负载系统迁移经验,提供企业核心业务大表结构变更、分步平滑迁移设计及自动化防护配置服务。 |
| 核心功能 | 遗留数据库变更风险体检、定制化 strong_migrations 规则集开发、大表分步迁移演练方案设计与应急保障 |
| 目标用户 | 业务高速增长且数据库单表体量达数千万/亿级的中大型 Rails 科技公司 |
| 难度/周期 | 低 · 2 - 4 周 · 成本:近乎零成本(主要消耗个人专业技术时间) |
| 收费模式 | 按咨询项目制收费或按月收取架构顾问费用 |
| 竞争风险 | 服务交付难以标准化扩张,高度依赖个人信誉和销售渠道。 |
| 依据 | 已验证事实 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
| 项目 | 中文简介 | Stars | 语言 |
|---|---|---|---|
| fresha/strong_migrations | 中文介绍暂未生成 Catch unsafe migrations in your Elixir application |
60 | Elixir |
| mzabani/codd | 中文介绍暂未生成 Codd is a simple-to-use CLI tool that applies plain postgres |
47 | Haskell |
| Phamdung2009/xxx | 中文介绍暂未生成 <!DOCTYPE html> <html lang="en"> <head> <title>Bitbuck |
20 | - |
| malikad778/Laravel-migration-guard | 中文介绍暂未生成 Catch dangerous Laravel migrations before they reach product |
18 | PHP |
| soartec-lab/prisma-strong-migrations | 中文介绍暂未生成 Catch unsafe Prisma migrations before they run. Detects dang |
13 | TypeScript |
| Sprinting-Software/nestjs-primer | 中文介绍暂未生成 A NestJS primer project with typeorm, schema migrations, dat |
3 | TypeScript |
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。
项目优势与风险
| 技术成熟度 | 创建于 2015-11-23,近 30 天仍在推送 |
| 社区活跃 | Star 4,463 / Fork 202 / Issue 5(数据支持,可自行核实) |
| 许可证 | MIT |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
快速开始(以仓库 README 为准)
git clone https://github.com/ankane/strong_migrations.git cd strong_migrations # 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。