def create_view(name, version: nil, sql_definition: nil, materialized: false)
      if version.present? && sql_definition.present?
        raise(
          ArgumentError,
          "sql_definition and version cannot both be set",
        )
      end

      if version.blank? && sql_definition.blank?
        version = 1
      end

      sql_definition ||= definition(name, version)

      if materialized
        Scenic.database.create_materialized_view(
          name,
          sql_definition,
          no_data: no_data(materialized),
        )
      else
        Scenic.database.create_view(name, sql_definition)
      end
    end
def create_view(name, version: nil, sql_definition: nil, materialized: false)
      if version.present? && sql_definition.present?
        raise(
          ArgumentError,
          "sql_definition and version cannot both be set",
        )
      end

      if version.blank? && sql_definition.blank?
        version = 1
      end

      sql_definition ||= definition(name, version)

      if materialized
        Scenic.database.create_materialized_view(
          name,
          sql_definition,
          no_data: no_data(materialized),
        )
      else
        Scenic.database.create_view(name, sql_definition)
      end
    end
Create a new database view.

 @param name [String, Symbol] The name of the database view.
 @param version [Fixnum] The version number of the view, used to find the
   definition file in `db/views`. This defaults to `1` if not provided.
 @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 materialized [Boolean, Hash] Set to true to create a materialized
   view. Set to { no_data: true } to create materialized view without
   loading data. Defaults to false.
 @return The database response from executing the create statement.

 @example Create from `db/views/searches_v02.sql`
   create_view(:searches, version: 2)

 @example Create from provided SQL string
   create_view(:active_users, sql_definition: <<-SQL)
     SELECT * FROM users WHERE users.active = 't'
   SQL