migflow 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +44 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +45 -0
  5. data/CLAUDE.md +124 -0
  6. data/CODE_OF_CONDUCT.md +132 -0
  7. data/CONTRIBUTING.md +157 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +218 -0
  10. data/Rakefile +11 -0
  11. data/SECURITY.md +27 -0
  12. data/app/assets/migflow/app.css +1 -0
  13. data/app/assets/migflow/app.js +28 -0
  14. data/app/assets/migflow/index.html +14 -0
  15. data/app/assets/migflow/vite.svg +1 -0
  16. data/app/controllers/migflow/api/diff_controller.rb +73 -0
  17. data/app/controllers/migflow/api/migrations_controller.rb +97 -0
  18. data/app/controllers/migflow/application_controller.rb +62 -0
  19. data/app/views/migflow/application/index.html.erb +16 -0
  20. data/config/routes.rb +10 -0
  21. data/docs/architecture.md +130 -0
  22. data/lib/migflow/analyzers/audit_analyzer.rb +58 -0
  23. data/lib/migflow/analyzers/rules/base_rule.rb +32 -0
  24. data/lib/migflow/analyzers/rules/dangerous_migration_rule.rb +44 -0
  25. data/lib/migflow/analyzers/rules/missing_foreign_key_rule.rb +30 -0
  26. data/lib/migflow/analyzers/rules/missing_index_rule.rb +32 -0
  27. data/lib/migflow/analyzers/rules/missing_timestamps_rule.rb +38 -0
  28. data/lib/migflow/analyzers/rules/null_column_without_default_rule.rb +46 -0
  29. data/lib/migflow/analyzers/rules/string_without_limit_rule.rb +28 -0
  30. data/lib/migflow/app/assets/migflow/app.css +1 -0
  31. data/lib/migflow/app/assets/migflow/app.js +17 -0
  32. data/lib/migflow/app/assets/migflow/index.html +14 -0
  33. data/lib/migflow/app/assets/migflow/vite.svg +1 -0
  34. data/lib/migflow/configuration.rb +36 -0
  35. data/lib/migflow/engine.rb +14 -0
  36. data/lib/migflow/models/migration_snapshot.rb +15 -0
  37. data/lib/migflow/models/schema_diff.rb +9 -0
  38. data/lib/migflow/models/warning.rb +7 -0
  39. data/lib/migflow/parsers/migration_parser.rb +52 -0
  40. data/lib/migflow/parsers/schema_parser.rb +105 -0
  41. data/lib/migflow/reporters/json_reporter.rb +13 -0
  42. data/lib/migflow/reporters/markdown_reporter.rb +58 -0
  43. data/lib/migflow/reporters.rb +38 -0
  44. data/lib/migflow/services/diff_builder.rb +77 -0
  45. data/lib/migflow/services/migration_dsl_scanner.rb +161 -0
  46. data/lib/migflow/services/migration_summary_builder.rb +43 -0
  47. data/lib/migflow/services/report_generator.rb +76 -0
  48. data/lib/migflow/services/risk_scorer.rb +38 -0
  49. data/lib/migflow/services/schema_builder.rb +25 -0
  50. data/lib/migflow/services/schema_patch_builder.rb +237 -0
  51. data/lib/migflow/services/scoped_migration_warnings.rb +93 -0
  52. data/lib/migflow/services/snapshot_builder.rb +542 -0
  53. data/lib/migflow/services/touched_tables_from_migration.rb +60 -0
  54. data/lib/migflow/version.rb +5 -0
  55. data/lib/migflow.rb +20 -0
  56. data/lib/tasks/migflow.rake +31 -0
  57. data/sig/migflow.rbs +3 -0
  58. metadata +124 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5d55af79f429534cba3daaff17a931b4ab66da0d78e0d183c96beb1101a70c91
4
+ data.tar.gz: cf93ff82fddc5c3e14d969fc0b25a8aea21415ec601d841f8406661dadb677b6
5
+ SHA512:
6
+ metadata.gz: ac99ca3d89000e918cadeb4964abf7398ec5b80f4776b6ffac93e53f35eb4407d3964a3ca057028d3bafa14f7e6ab07406a36c09222c1ac996ada95f56c460c3
7
+ data.tar.gz: ba27f668b0d91263c48a4050bb42a2e2bd796f4e099c76beb59160edb62a039b8f75bf32e4d11ab7756664c5eefa80e3c06d3df582f19a7b72e0b7107d5b6235
data/.rubocop.yml ADDED
@@ -0,0 +1,44 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.2
3
+ NewCops: enable
4
+
5
+ Style/StringLiterals:
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ EnforcedStyle: double_quotes
10
+
11
+ # Internal engine; class/module doc comments add noise without public API docs.
12
+ Style/Documentation:
13
+ Enabled: false
14
+
15
+ # Defaults (e.g. MethodLength Max: 10) are too strict for this codebase.
16
+ Metrics/AbcSize:
17
+ Max: 60
18
+
19
+ Metrics/ClassLength:
20
+ Max: 500
21
+
22
+ Metrics/CyclomaticComplexity:
23
+ Max: 15
24
+
25
+ Metrics/MethodLength:
26
+ Max: 55
27
+ CountComments: false
28
+
29
+ Metrics/PerceivedComplexity:
30
+ Max: 18
31
+
32
+ Naming/PredicatePrefix:
33
+ Enabled: false
34
+
35
+ Naming/PredicateMethod:
36
+ Enabled: false
37
+
38
+ Metrics/BlockLength:
39
+ Exclude:
40
+ - "spec/**/*"
41
+
42
+ Layout/LineLength:
43
+ Exclude:
44
+ - "spec/**/*"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,45 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.0] - 2026-04-22
11
+
12
+ ### Fixed
13
+ - Infinite "Loading schemas…" spinner in Flow and Schema views caused by `loadingBasePrevious` blocking rendering even when the previous-migration query was disabled or optional
14
+
15
+ ### Added
16
+ - **Risk score** — every migration receives a numeric score (0–100) and a level (safe / low / medium / high) derived from six audit rules, displayed in the detail panel and exposed in the API
17
+ - **CI report** — `bundle exec rails migflow:report` generates a Markdown or JSON audit report without starting a server; supports `FORMAT`, `FAIL_ON`, `FAIL_ON_SCORE`, and `OUTPUT` options
18
+ - **GitHub Actions workflow** — `.github/workflows/ci-report.yml` triggers on pull requests touching `db/migrate/` and posts a Markdown summary to the step summary
19
+ - `JsonReporter` and `MarkdownReporter` classes for structured report output
20
+ - `ReportGenerator` service orchestrating parser → snapshot → diff → risk scoring pipeline
21
+
22
+ ### Changed
23
+ - Minimum Ruby version raised to 3.2 (`Data.define` is not available in 3.1)
24
+ - CI matrix extended to Ruby 3.2 and 3.3 across Rails 7.0, 7.1, and 7.2
25
+ - RuboCop `TargetRubyVersion` aligned to 3.2
26
+
27
+ ## [0.1.0] - 2026-02-28
28
+
29
+ ### Added
30
+ - Rails engine mounting at a configurable path (default `/migflow`)
31
+ - Migration timeline — ordered list of all migrations with version, name, and one-line summary
32
+ - Detail view — raw migration source, schema snapshot (`schema_after`), and audit warnings
33
+ - Schema diff — focused and full unified diff of `schema.rb` between any two versions
34
+ - Compare mode — pick any two migration versions to see a side-by-side schema delta
35
+ - Schema graph (ERD) — interactive canvas with tables, columns, foreign-key edges, and diff highlights (added/removed coloring)
36
+ - Audit rules: `MissingIndexRule`, `MissingForeignKeyRule`, `StringWithoutLimitRule`, `MissingTimestampsRule`, `DangerousMigrationRule`, `NullColumnWithoutDefaultRule`
37
+ - REST API (`GET /api/migrations`, `GET /api/migrations/:version`, `GET /api/diff`)
38
+ - Authentication hooks — `parent_controller`, `authentication_hook`, `unauthenticated_redirect`
39
+ - `bin/setup` for one-command development setup
40
+ - CI pipeline with RSpec, RuboCop, Vitest, ESLint, and frontend build
41
+ - SimpleCov coverage enforcement (80% minimum)
42
+
43
+ [Unreleased]: https://github.com/jv4lentim/migflow/compare/v0.2.0...HEAD
44
+ [0.2.0]: https://github.com/jv4lentim/migflow/compare/v0.1.0...v0.2.0
45
+ [0.1.0]: https://github.com/jv4lentim/migflow/releases/tag/v0.1.0
data/CLAUDE.md ADDED
@@ -0,0 +1,124 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ ### Backend (Ruby gem)
8
+
9
+ ```bash
10
+ bundle exec rake # run tests + lint (default)
11
+ bundle exec rake spec # run RSpec tests only
12
+ bundle exec rspec spec/path/to/file_spec.rb # run a single spec file
13
+ bundle exec rspec spec/path/to/file_spec.rb:42 # run a single example by line
14
+ bundle exec rubocop # lint
15
+ bundle exec rubocop -a # auto-correct safe offenses
16
+ ```
17
+
18
+ ### Frontend (React/TypeScript)
19
+
20
+ ```bash
21
+ npm ci # install dependencies
22
+ npm test # run Vitest unit tests
23
+ npm run lint # ESLint
24
+ npm run build # build to app/assets/
25
+ npm run dev # dev server (Vite)
26
+ ```
27
+
28
+ ### Environment matrix (CI)
29
+
30
+ Tests run across Ruby 3.2/3.3 × Rails 7.0/7.1/7.2. Set `RAILS_VERSION` env var when running locally against a specific version (see Gemfile).
31
+
32
+ ## Architecture
33
+
34
+ Migflow is a **mountable Rails engine** that provides migration visualization, schema diffs, and audit warnings via a REST API consumed by a React SPA.
35
+
36
+ ### Data flow
37
+
38
+ ```
39
+ db/migrate/*.rb → MigrationParser → Array<MigrationSnapshot>
40
+ db/schema.rb → SchemaParser → Hash of tables/columns/indexes
41
+
42
+ MigrationSnapshot → MigrationDslScanner → SnapshotBuilder
43
+ (replays DSL calls to reconstruct
44
+ schema state at any point in history)
45
+
46
+ before_snapshot + after_snapshot → DiffBuilder → SchemaDiff
47
+ → SchemaPatchBuilder → unified diff hunks
48
+ → AuditAnalyzer + 6 rules → Array<Warning>
49
+ → MigrationSummaryBuilder → human summary
50
+ ```
51
+
52
+ ### Key layers
53
+
54
+ | Layer | Location | Purpose |
55
+ |---|---|---|
56
+ | Parsers | `lib/migflow/parsers/` | Extract raw metadata from files on disk |
57
+ | Models | `lib/migflow/models/` | Immutable `Data.define` value objects |
58
+ | Services | `lib/migflow/services/` | Business logic (snapshot, diff, patch, summary) |
59
+ | Analyzers | `lib/migflow/analyzers/` | Audit rules returning `Warning` objects |
60
+ | Controllers | `app/controllers/migflow/api/` | JSON REST API |
61
+ | Frontend | `frontend/src/` | React SPA (Timeline, ERD canvas, diff panel) |
62
+
63
+ ### API endpoints (mounted at `/migflow`)
64
+
65
+ - `GET /api/migrations` — list all migrations with summaries
66
+ - `GET /api/migrations/:id` — detail: schema before/after, patch hunks, warnings
67
+ - `GET /api/diff?from=&to=` — compare two arbitrary migration versions
68
+
69
+ ### `SnapshotBuilder` — the core engine
70
+
71
+ `SnapshotBuilder` is the most complex service. It replays migration DSL calls sequentially using `MigrationDslScanner` (regex-based parser for `create_table`, `add_column`, `add_index`, `add_foreign_key`, etc.) to reconstruct exact schema state at any historical point. Understanding this file is essential before touching snapshot or diff logic.
72
+
73
+ ### Audit rules (`lib/migflow/analyzers/rules/`)
74
+
75
+ Six rule classes, each implementing `#check(migration_content, tables:) → Array<Warning>`:
76
+ - `MissingIndexRule` — unindexed foreign keys
77
+ - `MissingForeignKeyRule` — `_id` columns without DB constraints
78
+ - `StringWithoutLimitRule` — string columns without `:limit`
79
+ - `MissingTimestampsRule` — tables missing `created_at`/`updated_at`
80
+ - `DangerousMigrationRule` — destructive ops (`remove_column`, `drop_table`, `rename_column`)
81
+ - `NullColumnWithoutDefaultRule` — `null: false` column added without `:default`
82
+
83
+ ### Frontend
84
+
85
+ State is managed with **Zustand** (`src/store/`) and server state with **@tanstack/react-query**. The ERD canvas uses **@xyflow/react**. Build output lands in `app/assets/` and is served by the engine's asset pipeline.
86
+
87
+ ## Conventions
88
+
89
+ - Commits follow **Conventional Commits** (`feat:`, `fix:`, `chore:`, etc.)
90
+ - Code coverage minimum: **80%** (enforced by SimpleCov in CI)
91
+ - String literals use **double quotes** (RuboCop enforced)
92
+ - Models use `Data.define` (Ruby 3.2+), not plain structs or `Struct.new`
93
+ - RuboCop metrics are relaxed (AbcSize: 60, MethodLength: 55) — do not lower them without discussion
94
+
95
+ ## Development guidelines
96
+
97
+ ### After every change
98
+
99
+ Always run the relevant checks after writing or modifying code — do not report a task complete before doing this:
100
+
101
+ - **New feature / new files:** update `CLAUDE.md` (architecture section if the new layer/service/rule is non-trivial), `README.md` (if the feature is user-facing — new API endpoint, config option, or UI capability), and `CONTRIBUTING.md` (if the feature introduces a new pattern contributors must follow). Skip a file only when the change genuinely does not affect it.
102
+
103
+
104
+ - **Backend change:** `bundle exec rspec` then `bundle exec rubocop`
105
+ - **Frontend change:** `npm test` then `npm run lint` then `npm run build`
106
+ - **Both touched:** run all five
107
+
108
+ If any check fails, fix it before finishing.
109
+
110
+ ### Ruby / Rails
111
+
112
+ - **SRP:** one class, one reason to change. Controllers only serialize/delegate; services own business logic; parsers own I/O and extraction. Do not mix concerns.
113
+ - **No fat services:** if a service method exceeds ~15 lines or handles more than one distinct concern, extract a collaborator.
114
+ - **DRY:** extract shared logic to a private method or a dedicated class. Never duplicate non-trivial logic across files.
115
+ - **No code smells:** avoid long parameter lists (prefer keyword args), deep conditional nesting, feature envy, and primitive obsession (use value objects / `Data.define`).
116
+ - **Query objects / service objects over callbacks:** keep models as plain value objects; do not add ActiveRecord callbacks or business logic to them.
117
+ - **Explicit over magic:** prefer explicit method calls over `method_missing`, `define_method` loops, or `send` unless there is a strong justification.
118
+
119
+ ### React / TypeScript
120
+
121
+ - **SRP for components:** one component, one visual responsibility. Extract sub-components when a component grows beyond ~80 lines or handles more than one distinct piece of UI.
122
+ - **No business logic in components:** keep components presentational. Data fetching belongs in hooks (`src/hooks/`) or query hooks (`@tanstack/react-query`); derived state belongs in utils (`src/utils/`).
123
+ - **DRY hooks:** shared stateful logic (e.g., selecting a migration, toggling a panel) belongs in a custom hook, not copy-pasted across components.
124
+ - **Type everything:** no implicit `any`. Define domain types in `src/types/` and reuse them.
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ joaovictorvalentim@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,157 @@
1
+ # Contributing to Migflow
2
+
3
+ Thank you for your interest in contributing. This document covers everything you need to get started.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ - [Getting started](#getting-started)
10
+ - [Workflow](#workflow)
11
+ - [Commit conventions](#commit-conventions)
12
+ - [Validation](#validation)
13
+ - [Backend guidelines](#backend-guidelines)
14
+ - [Frontend guidelines](#frontend-guidelines)
15
+ - [Opening a pull request](#opening-a-pull-request)
16
+
17
+ ---
18
+
19
+ ## Getting started
20
+
21
+ **Prerequisites:** Ruby 3.3, Node 22.
22
+
23
+ ```bash
24
+ git clone https://github.com/jv4lentim/migflow.git
25
+ cd migflow
26
+ bin/setup
27
+ ```
28
+
29
+ `bin/setup` installs Ruby gems and frontend dependencies in one step.
30
+
31
+ ---
32
+
33
+ ## Workflow
34
+
35
+ 1. **Open an issue first** for bugs or features — agree on the approach before writing code.
36
+ 2. Fork the repo and create a branch from `main`:
37
+ ```bash
38
+ git checkout -b fix/missing-index-warning
39
+ ```
40
+ 3. Make your changes, keep commits focused (one logical change per commit).
41
+ 4. Run the full validation suite locally before pushing (see [Validation](#validation)).
42
+ 5. Open a pull request against `main`.
43
+
44
+ Branch naming conventions:
45
+
46
+
47
+ | Prefix | Use for |
48
+ | ----------- | ------------------------------------ |
49
+ | `feat/` | New features |
50
+ | `fix/` | Bug fixes |
51
+ | `ci/` | CI/CD changes |
52
+ | `docs/` | Documentation only |
53
+ | `refactor/` | Refactoring without behavior change |
54
+ | `chore/` | Maintenance (deps, tooling, configs) |
55
+
56
+
57
+ ---
58
+
59
+ ## Commit conventions
60
+
61
+ Migflow follows [Conventional Commits](https://www.conventionalcommits.org/).
62
+
63
+ ### Format
64
+
65
+ ```
66
+ <type>(<optional scope>): <short description>
67
+
68
+ <optional body — explain the WHY, not the what>
69
+ ```
70
+
71
+ ### Rules
72
+
73
+ - **Subject line:** 72 characters max, imperative mood, no period at the end.
74
+ - **Body:** use it when the why is not obvious. Separate from subject with a blank line.
75
+ - **Breaking changes:** add `!` after the type and a `BREAKING CHANGE:` footer.
76
+
77
+ ### Types
78
+
79
+
80
+ | Type | Use for |
81
+ | ---------- | ---------------------------------------------------- |
82
+ | `feat` | New user-facing feature |
83
+ | `fix` | Bug fix |
84
+ | `ci` | CI/CD pipeline changes (workflows, scripts) |
85
+ | `docs` | Documentation only |
86
+ | `refactor` | Code change with no behavior change |
87
+ | `test` | Adding or fixing tests |
88
+ | `chore` | Maintenance — deps, tooling, configs that are not CI |
89
+ | `perf` | Performance improvement |
90
+
91
+
92
+ ### Examples
93
+
94
+ ```
95
+ feat(warnings): add null column without default rule
96
+
97
+ fix(parser): handle migrations with frozen string literal comment
98
+
99
+ ci: add Ruby/Rails compatibility matrix to backend job
100
+
101
+ docs: add compatibility table to README
102
+
103
+ chore: bump rubocop to 1.70
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Validation
109
+
110
+ Run these before opening a PR. All must pass.
111
+
112
+ ```bash
113
+ # Backend tests
114
+ bundle exec rake spec
115
+
116
+ # Ruby linter
117
+ bundle exec rubocop
118
+
119
+ # Frontend — from the frontend/ directory
120
+ npm ci
121
+ npm run lint
122
+ npm test
123
+ npm run build
124
+ ```
125
+
126
+ The CI pipeline runs the same steps across Ruby 3.2/3.3 × Rails 7.0/7.1/7.2. If your change is only backend, you do not need to rebuild frontend assets.
127
+
128
+ ---
129
+
130
+ ## Backend guidelines
131
+
132
+ - Logic lives in `lib/migflow/` — keep it framework-agnostic where possible.
133
+ - Controllers under `app/controllers/migflow/` should stay thin: delegate to services.
134
+ - New rules belong in `lib/migflow/analyzers/rules/`, inheriting from `BaseRule`.
135
+ - Write RSpec specs for every new class. Keep unit tests isolated from Rails when the class does not need it.
136
+ - Do not lower the SimpleCov threshold (currently 80%). New code must be covered.
137
+
138
+ ---
139
+
140
+ ## Frontend guidelines
141
+
142
+ - Components live in `frontend/src/components/`.
143
+ - Use TypeScript. Avoid `any`.
144
+ - New components need at least a render test with Vitest + Testing Library.
145
+ - Do not add new npm dependencies without discussing in the issue first.
146
+ - Keep the bundle size in mind — check `npm run build` output for size regressions.
147
+
148
+ ---
149
+
150
+ ## Opening a pull request
151
+
152
+ - Fill in the PR description with what changed and why.
153
+ - Link the related issue (`Closes #N`).
154
+ - Keep PRs focused — one concern per PR is easier to review and revert.
155
+ - A PR that only touches documentation does not need new tests.
156
+ - Maintainers may ask for changes; address them in new commits (do not force-push during review).
157
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Joao Victor Valentim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.