Sha256: df5b0175d0a211253e9764251ddb8a34d457eed4b52865383df68bc410340cb8

Contents?: true

Size: 559 Bytes

Versions: 5

Compression:

Stored size: 559 Bytes

Contents

# frozen_string_literal: true

class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VERSION::MAJOR < 5 ? '' : '[5.0]' %>
  def up
    execute <<-SQL
    CREATE OR REPLACE VIEW <%= view_name %> AS

    SELECT UNNEST
      ( <%= source_column_name %> ) AS <%= source_column_name.singularize %>_name,
      COUNT ( * ) AS taggings_count
    FROM
      <%= source_table_name %>
    GROUP BY
      <%= source_column_name.singularize %>_name;
    SQL
  end

  def down
    execute <<-SQL
      DROP VIEW <%= view_name %>;
    SQL
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
metka-1.0.3 lib/generators/metka/strategies/view/templates/migration.rb.erb
metka-1.0.2 lib/generators/metka/strategies/view/templates/migration.rb.erb
metka-1.0.1 lib/generators/metka/strategies/view/templates/migration.rb.erb
metka-1.0.0 lib/generators/metka/strategies/view/templates/migration.rb.erb
metka-0.1.2 lib/generators/metka/strategies/view/templates/migration.rb.erb