Sha256: f28c55768bc3b4f5723ff001f1759f4ce400d676129fc125b812347e77de7b8a

Contents?: true

Size: 1.09 KB

Versions: 24

Compression:

Stored size: 1.09 KB

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
        if ActiveRecord::VERSION::STRING.to_f >= 6.1
          ActiveRecord::Base.connection_db_config.adapter.to_s
        else
          ActiveRecord::Base.connection_config[:adapter].to_s
        end
      end

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
strong_migrations-1.8.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.7.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.6.4 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.6.3 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.6.2 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.6.1 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.6.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.5.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.4.4 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.4.3 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.4.2 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.4.1 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.4.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.3.2 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.3.1 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.3.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.2.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.1.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-1.0.0 lib/generators/strong_migrations/install_generator.rb
strong_migrations-0.8.0 lib/generators/strong_migrations/install_generator.rb