Class: Brick::MigrationsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Brick::MigrationsGenerator
- Includes:
- MigrationBuilder, FancyGets
- Defined in:
- lib/generators/brick/migrations_generator.rb
Overview
Auto-generates migration files
Constant Summary
Constants included from MigrationBuilder
Brick::MigrationBuilder::SQL_TYPES
Instance Method Summary collapse
Methods included from MigrationBuilder
check_folder, generate_migrations
Instance Method Details
#brick_migrations ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/brick/migrations_generator.rb', line 17 def brick_migrations # If Apartment is active, see if a default schema to analyse is indicated ::Brick.mode = :on ActiveRecord::Base.establish_connection if (tables = ::Brick.relations.reject { |k, v| k.is_a?(Symbol) || v.key?(:isView) && v[:isView] == true }.map(&:first).sort).empty? puts "No tables found in database #{ActiveRecord::Base.connection.current_database}." return end mig_path, is_insert_versions, is_delete_versions = ::Brick::MigrationBuilder.check_folder return unless mig_path # Generate a list of tables that can be chosen chosen = gets_list(list: tables, chosen: tables.dup) ::Brick::MigrationBuilder.generate_migrations(chosen, mig_path, is_insert_versions, is_delete_versions) end |