Sha256: b4b7b79e92ba0b40295e40e363ecbe98bbea2cc9e35ca3df516ebb5a015a51ec

Contents?: true

Size: 970 Bytes

Versions: 2

Compression:

Stored size: 970 Bytes

Contents

require "rails/generators"

module StrongMigrations
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.join(__dir__, "templates")

      def create_initializer
        template "initializer.rb", "config/initializers/strong_migrations.rb"
      end

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

      def pgbouncer_message
        if postgresql?
          "\n# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user"
        end
      end

      def target_version
        case adapter
        when /mysql/
          # could try to connect to database and check for MariaDB
          # but this should be fine
          '"8.0.12"'
        else
          "10"
        end
      end

      def adapter
        ActiveRecord::Base.connection_config[:adapter].to_s
      end

      def postgresql?
        adapter =~ /postg/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
strong_migrations-0.7.5 lib/generators/strong_migrations/install_generator.rb
strong_migrations-0.7.4 lib/generators/strong_migrations/install_generator.rb