scenic
Scenic is a Ruby gem that simplifies managing SQL database views in Rails applications through migrations. It provides versioning, generators, and support for both regular and materialized views with PostgreSQL.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | scenic-views/scenic |
| Owner | scenic-views |
| Primary language | Ruby |
| License | MIT — OSI-approved |
| Stars | 3.6k |
| Forks | 243 |
| Open issues | 33 |
| Latest release | v1.4.0 (2017-05-19) |
| Last updated | 2026-06-29 |
| Source | https://github.com/scenic-views/scenic |
What scenic is
Scenic extends ActiveRecord::Migration with DSL methods (create_view, update_view, replace_view, drop_view) to manage database views as versioned SQL files. It supports regular views, materialized views, concurrent refresh, and side-by-side update strategies while maintaining schema.rb compatibility.
Get the scenic source
Clone the repository and explore it locally.
git clone https://github.com/scenic-views/scenic.gitcd scenic# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- View definitions live in db/views/*.sql files; establish team conventions for SQL style, naming (versioning), and code review before adoption.
- Declare primary_key explicitly on view-backed models; ActiveRecord cannot infer it from view columns, and readonly? should be overridden to prevent failed save attempts.
- Plan view update strategy upfront: drop-and-recreate (default), CREATE OR REPLACE (--replace), or side-by-side (materialized views) each have different locking/downtime implications.
- Materialized view concurrent refresh requires PostgreSQL 9.4+, unique indexes covering all rows, and careful planning of cascading dependencies.
- Test SQL in postgres console during development; Scenic does not validate or optimize SQL, only manages versioning and migration mechanics.
When to avoid it — and what to weigh
- Database Agnostic Requirements — Currently only supports PostgreSQL. MySQL and SQLite support exists only via third-party adapters (not officially maintained); requires careful evaluation.
- Write-Heavy or High-Frequency Materialized View Updates — Materialized view refresh locks the view during concurrent operations; not suitable for real-time data scenarios or applications with constant refresh needs.
- Non-Rails Stacks — Tightly coupled to Rails migrations and ActiveRecord conventions; not applicable for non-Rails applications or heterogeneous database management approaches.
- Avoiding SQL File Management — Requires maintaining separate SQL definition files in version control alongside migrations; adds operational overhead if your team prefers pure Ruby DSLs.
License & commercial use
MIT License. Permissive OSI-approved license allowing commercial use, modification, and distribution with attribution and no warranty.
MIT license explicitly permits commercial use. No observed licensing restrictions in provided data. Verify with legal review if your organization requires formal license audits.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Moderate |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Moderate |
| DEV.co fit | Good |
| Assessment confidence | Medium |
Views execute arbitrary SQL within database connection context; audit SQL definitions for SQL injection risks, especially in user-supplied parameters. Views inherit database-level access control; ensure proper role and permission policies on underlying tables. No explicit security advisories or threat model documented.
Alternatives to consider
raw SQL migrations + schema.rb DSL
Use if you prefer explicit SQL in migrations without file management overhead, though you lose versioning convenience and SQL editor highlighting.
Arel / ActiveRecord query objects
Simpler for moderately complex queries without database view semantics; no migration overhead but less performant for expensive recurring queries.
Native database migrations (psql scripts)
Maximum flexibility outside Rails conventions but loses migration reversibility, schema.rb tracking, and ActiveRecord integration unless manually managed.
Build on scenic with DEV.co software developers
Scenic streamlines SQL view management in Rails. Let our team help you architect and integrate database views into your application stack.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
scenic FAQ
Can I back an ActiveRecord model with a Scenic view?
What databases does Scenic support?
How do I update a view without dropping it?
Does Scenic validate or optimize my SQL?
Custom software development services
From first prototype to production, DEV.co delivers software development services around tools like scenic. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source databases and beyond.
Ready to Simplify Your Database Views?
Scenic streamlines SQL view management in Rails. Let our team help you architect and integrate database views into your application stack.