Sha256: f64075f913eeb16c63fd625ad28b61ccab449d8fab1b1ab4fe402bf18cbf2016

Contents?: true

Size: 483 Bytes

Versions: 1

Compression:

Stored size: 483 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 name,
      COUNT ( * ) AS taggings_count
    FROM
      <%= source_table_name %>
    GROUP BY
      name;
    SQL
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metka-0.1.0 lib/generators/metka/strategies/view/templates/migration.rb.erb