Class: PGTrunk::Operations::MaterializedViews::ChangeMaterializedView
- Inherits:
-
Base
- Object
- PGTrunk::Operation
- Base
- PGTrunk::Operations::MaterializedViews::ChangeMaterializedView
- Defined in:
- lib/pg_trunk/operations/materialized_views/change_materialized_view.rb
Instance Method Summary collapse
- #invert ⇒ Object
-
#rename_column(name, to:) ⇒ Object
A method to be called in a block.
- #to_sql(_version) ⇒ Object
Methods inherited from Base
Methods included from PGTrunk::Operation::SQLHelpers
Methods included from PGTrunk::Operation::RubyHelpers
#dump, #to_a, #to_opts, #to_ruby
Methods included from PGTrunk::Operation::Inversion
Methods included from PGTrunk::Operation::Validations
Methods included from PGTrunk::Operation::Attributes
Instance Method Details
#invert ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/pg_trunk/operations/materialized_views/change_materialized_view.rb', line 91 def invert irreversible!("if_exists: true") if if_exists undefined = inversion.select { |_, v| v.nil? }.keys.join(", ").presence raise IrreversibleMigration.new(self, nil, <<~MSG.squish) if undefined Undefined values to revert #{undefined}. MSG self.class.new(name: name, **inversion) if inversion.any? end |
#rename_column(name, to:) ⇒ Object
A method to be called in a block
73 74 75 |
# File 'lib/pg_trunk/operations/materialized_views/change_materialized_view.rb', line 73 def rename_column(name, to:) columns << Column.new(name: name, new_name: to) end |
#to_sql(_version) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/pg_trunk/operations/materialized_views/change_materialized_view.rb', line 82 def to_sql(_version) [ *change_columns, *rename_columns, *cluster_view, *update_comment, ].join(" ") end |