Sha256: b620e46c5b619f7d4bc912980ff39fdbfd10c60b1d98424290e4f7ac9b8bf800

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

require 'rails/generators'
require 'tramway/core/generators/install_generator'

module Tramway::SportSchool::Generators
  class InstallGenerator < ::Tramway::Core::Generators::InstallGenerator
    include Rails::Generators::Migration
    source_root File.expand_path('templates', __dir__)

    def run_other_generators
      generate 'tramway:user:install'
      generate 'tramway:landing:install'
      generate 'tramway:profiles:install'
      generate 'tramway:news:install'
      generate 'tramway:page:install'
      generate 'ckeditor:install --orm=active_record --backend=carrierwave'
    end

    def self.next_migration_number(path)
      next_migration_number = current_migration_number(path) + 1
      ActiveRecord::Migration.next_migration_number next_migration_number
    end

    def copy_migrations
      migrations = %i[
        create_tramway_sport_school_kind_sports
        add_state_to_tramway_sport_school_kind_sports
        add_image_to_tramway_sport_school_kind_sports
        create_tramway_sport_school_trainers
        create_tramway_sport_school_documents
        add_degree_to_tramway_sport_school_trainers
        add_description_to_tramway_sport_school_trainers
        create_tramway_sport_school_institutions
        add_description_to_tramway_sport_school_kind_sports
        create_tramway_sport_school_organizations
        add_contacts_to_tramway_sport_school_institutions
        add_ll_to_tramway_sport_school_institutions
        add_document_type_to_tramway_sport_school_documents
        add_url_to_tramway_sport_school_institutions
        add_found_date_to_tramway_sport_school_institutions
        add_name_to_tramway_sport_school_institutions
        add_main_image_to_tramway_sport_school_institutions
        add_favicon_to_tramway_sport_school_institutions
      ]
      migrations.each do |migration|
        migration_template "#{migration}.rb", "db/migrate/#{migration}.rb"
      end
      ::Tramway::SportSchool::Institution.create!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tramway-sport_school-1.2.12.2 lib/tramway/sport_school/generates/install_generator.rb
tramway-sport_school-1.2.12.1 lib/tramway/sport_school/generates/install_generator.rb