Module: ActiveRecord::View::Integration::SchemaMethods
- Extended by:
- Utility, ActiveSupport::Concern
- Defined in:
- lib/activerecord/view/integration/schema_methods.rb
Constant Summary collapse
- CREATE_VIEW_FMT =
cleanup <<-SQL CREATE%<or_replace>s VIEW %<name>s AS %<body>s SQL
- DROP_VIEW_FMT =
cleanup <<-SQL DROP VIEW%<if_exists>s %<name>s%<restriction>s SQL
- CREATE_MATERIALIZED_VIEW_FMT =
cleanup <<-SQL CREATE%<or_replace>s MATERIALIZED VIEW %<name>s AS %<body>s %<with_data>s SQL
- DROP_MATERIALIZED_VIEW_FMT =
cleanup <<-SQL DROP MATERIALIZED VIEW%<if_exists>s %<name>s%<restriction>s SQL
- MATERIALIZED_VIEW_ADAPTERS =
%w[PostgreSQL PostGIS]
Class Method Summary collapse
-
.quote_table_name(name) ⇒ String
private
Stub method for tests.
Instance Method Summary collapse
-
#create_materialized_view(name, body = nil, force: false, **kwargs, &block) ⇒ void
Create a materialized view.
-
#create_view(name, body = nil, force: false, **kwargs, &block) ⇒ void
Create a SQL view.
-
#drop_materialized_view(name, **kwargs) ⇒ void
Drop a materialized view.
-
#drop_view(name, **kwargs) ⇒ void
Drop a SQL view.
Methods included from Utility
Class Method Details
.quote_table_name(name) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Stub method for tests.
171 172 173 |
# File 'lib/activerecord/view/integration/schema_methods.rb', line 171 def quote_table_name(name) %["#{name}"] end |
Instance Method Details
#create_materialized_view(name, body = nil, force: false, **kwargs, &block) ⇒ void
This method returns an undefined value.
Create a materialized view.
Only valid on Postgres.
54 55 56 57 58 59 60 |
# File 'lib/activerecord/view/integration/schema_methods.rb', line 54 def create_materialized_view(name, body = nil, force: false, **kwargs, &block) supports_materialized_view! drop_materialized_view(name) if force && table_exists?(name) execute build_create_materialized_view_query(name, body, **kwargs, &block) end |
#create_view(name, body = nil, force: false, **kwargs, &block) ⇒ void
This method returns an undefined value.
Create a SQL view.
30 31 32 33 34 35 36 |
# File 'lib/activerecord/view/integration/schema_methods.rb', line 30 def create_view(name, body = nil, force: false, **kwargs, &block) kwargs[:sqlite3] = !!(adapter_name =~ /sqlite/i) drop_view(name) if force && table_exists?(name) execute build_create_view_query(name, body, **kwargs, &block) end |
#drop_materialized_view(name, **kwargs) ⇒ void
This method returns an undefined value.
Drop a materialized view.
Only valid on Postgres.
68 69 70 71 72 |
# File 'lib/activerecord/view/integration/schema_methods.rb', line 68 def drop_materialized_view(name, **kwargs) supports_materialized_view! execute build_drop_materialized_view_query(name, **kwargs) end |
#drop_view(name, **kwargs) ⇒ void
This method returns an undefined value.
Drop a SQL view.
42 43 44 45 46 |
# File 'lib/activerecord/view/integration/schema_methods.rb', line 42 def drop_view(name, **kwargs) kwargs[:sqlite3] = !!(adapter_name =~ /sqlite/i) execute build_drop_view_query(name, **kwargs) end |