Build
Connect & operate
Design & teams
Start hereScope a build in one callBring a spec, a wireframe, or a paragraph. You leave with an architecture, a timeline, and a number.Book a scoping call
AI software
LLM & data systems
Vibe coding
Ready to ship?Put AI where the work isAgents, RAG, and private LLMs wired into the systems your team already uses — not a chatbot bolted to a homepage.Discuss an AI project
Domain firstWe learn your workflow before we model itRegulated, operational, or high-volume — the constraints belong in the schema, not in a training doc.Talk about your domain
Plan smarterEstimate before you commitCost ranges, scope templates, and the questions we ask in discovery — free, no form.Open the cost calculator
Real conversationsTalk with a technical leadNo SDR, no discovery gauntlet. The person on the call is the one who scopes the build.Book a call
Open-Source Databases · scenic-views

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.

Source: GitHub — github.com/scenic-views/scenic
3.6k
GitHub stars
243
Forks
Ruby
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryscenic-views/scenic
Ownerscenic-views
Primary languageRuby
LicenseMIT — OSI-approved
Stars3.6k
Forks243
Open issues33
Latest releasev1.4.0 (2017-05-19)
Last updated2026-06-29
Sourcehttps://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.

Quickstart

Get the scenic source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/scenic-views/scenic.gitcd scenic# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Complex Read-Heavy Reporting

Encapsulate complex multi-table joins and aggregations as views to simplify application queries and improve reusability across multiple models.

Materialized View Caching

Cache expensive query results using materialized views with concurrent refresh capability to improve query performance without modifying application code.

Domain Concept Promotion

Back ActiveRecord models with views to elevate complex relational patterns into first-class domain objects with clean, intention-revealing code.

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.

SignalAssessment
MaintenanceModerate
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceMedium
Security considerations

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.

Software development agency

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.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related 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?
Yes. Declare primary_key and override readonly? to prevent save attempts. Models behave like normal AR classes except writes will fail.
What databases does Scenic support?
Officially PostgreSQL only. MySQL and SQLite are supported via third-party adapters; verify adapter maintenance status before relying on them.
How do I update a view without dropping it?
Use --replace flag for CREATE OR REPLACE VIEW (non-materialized). For materialized views, use --side-by-side to avoid locking during refresh.
Does Scenic validate or optimize my SQL?
No. Scenic only manages versioning, file organization, and migration mechanics. Test SQL in postgres console; optimization and syntax validation are your responsibility.

From evaluation to production software

Bringing scenic into production usually means new services, new interfaces, and new failure modes. DEV.co is a software development agency that builds all three and stays on for the open-source databases maintenance.

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.