Sha256: 5cf50305887bba6ebcc88b343568708087cfab3053acdb619361a7618df4c8a8

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module Jabe
  module Generators
    class MigrationsGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      self.source_root(File.expand_path(File.join(Jabe::Engine.root, 'lib', 'generators', 'jabe', 'templates', 'migrations')))

      desc "run this generator to create the necessary migrations"

      def create_migrations
        existing_migrations = Dir["db/migrate/*.rb"]
        migrations = %w(
          create_settings.rb
          create_slugs.rb
          devise_create_admins.rb
          create_entries.rb
          create_comments.rb
          add_new_settings.rb
        ).reject { |file|
          existing_migrations.any? { |migration|
            match = migration.match(/#{file}$/)
            puts "skipping #{file}, exists." if match
            match
          }
        }

        migrations.each do |migration|
          migration_template migration, "db/migrate/#{migration}"
          sleep 1 # timestamps...
        end
      end

      def self.next_migration_number(dirname)
        Time.now.utc.strftime("%Y%m%d%H%M%S")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jabe-0.5.9 lib/generators/jabe/migrations/migrations_generator.rb
jabe-0.5.8 lib/generators/jabe/migrations/migrations_generator.rb