def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false)
      if version.blank? && sql_definition.blank?
        raise(
          ArgumentError,
          "sql_definition or version must be specified",
        )
      end

      if version.present? && sql_definition.present?
        raise(
          ArgumentError,
          "sql_definition and version cannot both be set",
        )
      end

      sql_definition ||= definition(name, version)

      if materialized
        Scenic.database.update_materialized_view(
          name,
          sql_definition,
          no_data: no_data(materialized),
        )
      else
        Scenic.database.update_view(name, sql_definition)
      end
    end
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false)
      if version.blank? && sql_definition.blank?
        raise(
          ArgumentError,
          "sql_definition or version must be specified",
        )
      end

      if version.present? && sql_definition.present?
        raise(
          ArgumentError,
          "sql_definition and version cannot both be set",
        )
      end

      sql_definition ||= definition(name, version)

      if materialized
        Scenic.database.update_materialized_view(
          name,
          sql_definition,
          no_data: no_data(materialized),
        )
      else
        Scenic.database.update_view(name, sql_definition)
      end
    end
Update a database view to a new version.

 The existing view is dropped and recreated using the supplied `version`
 parameter.

 @param name [String, Symbol] The name of the database view.
 @param version [Fixnum] The version number of the view.
 @param sql_definition [String] The SQL query for the view schema. An error
   will be raised if `sql_definition` and `version` are both set,
   as they are mutually exclusive.
 @param revert_to_version [Fixnum] The version number to rollback to on
   `rake db rollback`
 @param materialized [Boolean, Hash] True if updating a materialized view.
   Set to { no_data: true } to update materialized view without loading
   data. Defaults to false.
 @return The database response from executing the create statement.

 @example
   update_view :engagement_reports, version: 3, revert_to_version: 2