mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-04-30 05:31:36 +08:00
- Replace the YAML-based schema configuration with a Ruby DSL for defining intermediate database schemas - Add table builders, conventions, enums, ignored tables, and output config as composable DSL files in `migrations/config/schema/` - Implement schema resolver that combines DSL config with database introspection to produce resolved schemas - Add generator that produces SQL schema, Ruby models, and enum files from the resolved schema - Add scaffolder for bootstrapping new table configs and differ for comparing config against the database - Add plugin manifest and introspection system to auto-detect plugin-owned columns - Rewrite all schema CLI commands (`add`, `validate`, `diff`, `generate`, `list`, `ignore`, `refresh-plugins`) to use DSL infrastructure - Add comprehensive specs and documentation (`migrations/docs/schema-configuration.md`) - Remove old YAML config, JSON schema, and validation infrastructure
1.3 KiB
1.3 KiB
Migrations Tooling - AI Agent Guide
Running Tests
Tests must be run from the project root with --default-path migrations/spec:
bin/rspec --default-path migrations/spec
bin/rspec --default-path migrations/spec migrations/spec/lib/database/schema/dsl/
bin/rspec --default-path migrations/spec migrations/spec/path/to/file_spec.rb
CLI
The CLI binary is at migrations/bin/cli:
migrations/bin/cli help
migrations/bin/cli schema generate
migrations/bin/cli schema validate
migrations/bin/cli schema diff
Schema DSL
The schema DSL lives in migrations/lib/database/schema/dsl/. Config files are in migrations/config/schema/.
Key files:
table_builder.rb- DSL for defining table configsschema_resolver.rb- Resolves DSL config + DB introspection into final schemaconventions_builder.rb- Global column conventions (renames, type overrides)generator.rb- Generates SQL, models, and enums from resolved schemavalidator.rb- Validates DSL configresolved_schema_validator.rb- Validates resolved schema before generation
Linting
bin/lint path/to/file
bin/lint --fix path/to/file
Uses both rubocop and syntax_tree. Always lint changed files.
Gems
bundle config set --local with migrations
bundle install