scenic-views/scenic
55.9
Adequate · 28 September 2026
1.6k
lines of production code
Ruby
primary language
2
measurements over time
What this system is
This system is a Ruby gem that integrates with Rails to manage database views and materialized views. It provides generators for creating view definitions and migrations, along with adapter-specific logic for PostgreSQL to handle view creation, updates, and concurrent refreshes. The library supports versioned view management, allowing for atomic updates and reversible migrations to maintain schema integrity.
How it got here
2014 — Railtie migration and materialized view support
18 changes.
The project refactored its initialization from a Rails Engine to a Railtie and introduced comprehensive support for materialized views, including atomic updates and concurrent refreshes. This period also established a robust testing infrastructure with a dummy Rails application and expanded the generator suite to streamline view and model creation.
2015–2016 — Materialized view support and adapter refactoring
5 changes.
This period focused on extending the project to support materialized views, including new generator flags and a side-by-side update strategy. The Postgres adapter was refactored to handle cascading and concurrent refreshes while improving compatibility with older database versions. Comprehensive test coverage was added to validate these new features and adapter internals.
Features
Generated model templates now include materialized view helpers
The generated Scenic model templates now include two class methods: \refresh\, which delegates to \Scenic.database.refresh\_materialized\_view\ with default settings (non-concurrent, no cascade), and \populated?\, which checks if the materialized view has been populated. This allows users to easily manage and inspect the state of materialized views directly from their generated model classes.
lib/generators/scenic/model/templates · high confidence
Introduce scenic:view generator for creating and updating database views
Adds a new \scenic:view\ generator that creates database view definition files and accompanying migrations. The generator supports creating new views, updating existing ones by copying previous definitions, and handling materialized views with an optional \--no-data\ flag. It also ensures compatibility with different Rails versions by using \ActiveRecord::Migration.current\_version\ and properly handles schema-qualified view names.
lib/generators/scenic/view · high confidence
New model generator for database views
A new \scenic:model\ generator has been added, allowing users to create a database view, its corresponding SQL migration file, and an ActiveRecord model subclass in a single command. The generator delegates to the standard Rails model generator but suppresses fixture replacement and migration generation to avoid conflicts, while also invoking the existing scenic view generator. It supports creating materialized views via the \--materialized\ flag, which injects specific model methods into the generated class.
lib/generators/scenic/model · high confidence
Postgres adapter now supports materialized views and concurrent refreshes
The Postgres adapter in lib/scenic/adapters has been expanded to include full support for materialized views, introducing methods to create, update, and drop them. Users can now create materialized views without initial data population via the \no\_data\ option and perform atomic updates using the \side\_by\_side\ mode to minimize downtime. The adapter also supports concurrent refreshes for materialized views, provided the view is populated, and includes logic to maintain indexes during updates. Additionally, the adapter now checks for materialized view support based on the Postgres version and handles view name quoting and schema isolation more robustly.
lib/scenic/adapters · high confidence
Behavioural changes
Added binstubs for rake, rspec, standardrb, and yard
The project now includes dedicated binstubs in the bin directory for rake, rspec, standardrb, and yard. These scripts ensure that these tools are executed using the specific gem versions defined in the project's Gemfile, providing consistent behavior across different development environments and CI setups.
bin · high confidence
Convert Scenic from Rails Engine to Railtie with explicit loading
The library's initialization mechanism has changed from using a Rails Engine to a Railtie, requiring the new \Scenic.load\ method to be called to enable migration methods, reversibility, and schema dumping. This change also introduces a configurable database adapter system (defaulting to Postgres) and restructures internal requirements to support adapter-specific logic and view management.
lib · high confidence
Generated migrations for view creation and updates now include versioning and materialized view options
The templates for generating database migrations have been updated to support versioned view updates and materialized views. The new \update\_view.erb\ template generates migration code that calls \update\_view\ or \replace\_view\ with explicit \version\ and \revert\_to\_version\ parameters, and includes logic to pass \materialized\ options when dealing with materialized views. This allows users to manage view versions and materialization state directly through generated migrations.
lib/generators/scenic/view/templates · high confidence
Generators now support materialized views and a renamed replace flag
The migration generators now include options to create and manage materialized views, allowing users to specify \--materialized\ to generate a materialized view, \--no-data\ to create it without initial data, and \--side-by-side\ to use a side-by-side update strategy. Additionally, the \--replace\_view\ flag has been renamed to \--replace\ to simplify the command-line interface for replacing views during updates.
lib/generators/scenic · high confidence
Postgres adapter refactored to support cascading refreshes and older Postgres versions
The Postgres adapter has been rewritten to support cascading materialized view refreshes (refreshing dependent views in topological order) and concurrent refreshes on Postgres 9.4+. It now properly handles Postgres versions older than 9.3 by raising specific errors, correctly quotes view names to support unusual characters, and excludes system views like \pg\_stat\_statements\_info\ from dumps. The update process uses a side-by-side strategy to migrate indexes safely, and view sorting in schema dumps is now topologically ordered by dependencies.
lib/scenic/adapters/postgres · high confidence
Project documentation and configuration overhaul
The repository has been restructured with significant updates to its documentation and configuration files. A comprehensive CHANGELOG.md has been added, documenting features and fixes up to version 1.9.0, including the new \side\_by\_side\ mode for materialized view updates and topological sorting of views in schema dumps. The README.md has been expanded with detailed installation instructions, usage examples for views and models, and explanations of materialized view refresh strategies. New standard project files have been introduced, including a Code of Conduct, Contributing guidelines, Security Policy, and Funding configuration. Additionally, the \.yardopts\ file has been added to configure YARD documentation generation to hide private APIs and use Markdown, and the Rakefile has been updated to support RSpec tasks for unit and acceptance tests.
(repo-wide) · high confidence
Scenic v1.9.0: Migration to Railtie and new view management commands
Scenic has been refactored from a Rails Engine to a Railtie, changing how the gem initializes within a Rails application. This release introduces new migration capabilities for database views, including \replace\_view\ for atomic updates via \CREATE OR REPLACE VIEW\ (regular views only), and enhanced \update\_view\ support for materialized views with \side\_by\_side\ and \no\_data\ options to manage downtime and data loading. The schema dumper now includes materialized view indexes and respects Rails' internal table exclusions, while the \CommandRecorder\ ensures that \update\_view\ and \replace\_view\ migrations are reversible when a \revert\_to\_version\ is specified.
lib/scenic · high confidence
Test coverage
Added RSpec test infrastructure with database cleaning and Rails version compatibility; Added acceptance tests for view management; Added dummy Rails application for testing; Added integration tests for view revert functionality; Added test coverage for Postgres adapter internals; Added test coverage for Scenic view management and configuration; Added test coverage for the Postgres adapter; Added test fixtures for database schema and extensions; Added test suite configuration for the dummy Rails application; Added test support helpers for database schema, generators, and view definitions; Added tests for the Scenic view generator.
Dependencies
Update development dependencies and add runtime dependency on railties
The gem's development environment now includes explicit dependencies for database\_cleaner, pg, pry, ammeter, yard, redcarpet, and standard, while upgrading rspec to require version 3.3 or newer. Additionally, the gem now explicitly depends on railties (\>= 4.0.0) alongside the existing activerecord dependency, and requires Ruby version 2.3.0 or higher.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 58 → 56 (-2.6)
- Rubric changed (rubric-2026.09.8 → rubric-2026.09.16) — scores are not directly comparable.
Lenses
- Code Health 100 → 100 (+0.0)
- Architecture 100 → 68 (-32.0)
- Maturity 49 → 49 (+0.0)
- Readiness 41 → 45 (+3.7)
- Security 97 → 97 (+0.5)
New (3)
- Ambiguous distinction between update and replace. In database contexts, 'update' often implies a partial change or version increment, while 'replace' implies a full swap. However, without clear documentation or distinct signatures (e.g., one taking a diff, one taking full SQL), these names are semantically close and prone to misuse.
- Inconsistent naming for inversion methods. The methods are named invert_<action>, but the primary actions are create_view, drop_view, etc. While consistent within the class, the prefix 'invert' is verbose compared to standard Ruby conventions like revert_ or undo_. More importantly, invert_replace_view suggests a specific inversion logic for replace, whereas invert_update_view does the same for update. This is a minor stylistic issue but worth noting for API elegance.
- Redundant configuration accessors. configuration and configuration= provide standard getter/setter semantics, while configure likely serves a similar purpose (setting config) or is an alias. Having three ways to interact with configuration state is confusing.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
scenic-views/scenic was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 28 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit f2162dbddb0fb0eb5d4b04d640dcec5303a387e8 — the exact code this score is about.
- Scored under rubric-2026.09.16 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-2d9048c36d26.