Sha256: f9229ef8f071393672c75085e8ccc8ed3060334e6bf1aba1226db0e67dba7c47
Contents?: true
Size: 917 Bytes
Versions: 1
Compression:
Stored size: 917 Bytes
Contents
module Scenic module ActiveRecord module Statements def create_view(name, version: 1, sql_definition: nil) if version.nil? && sql_definition.nil? raise( ArgumentError, "view_definition or version_number must be specified" ) end sql_definition ||= definition(name, version) execute "CREATE VIEW #{name} AS #{sql_definition};" end def drop_view(name, revert_to_version: nil) execute "DROP VIEW #{name};" end def update_view(name, version: nil, revert_to_version: nil) if version.nil? raise ArgumentError, "version is required" end drop_view(name) create_view(name, version: version) end private def definition(name, version) File.read(::Rails.root.join("db", "views", "#{name}_v#{version}.sql")) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scenic-0.1.0 | lib/scenic/active_record/statements.rb |