Class: PgInsights::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PgInsights::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/pg_insights/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
12 13 14 |
# File 'lib/generators/pg_insights/install_generator.rb', line 12 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#copy_migrations ⇒ Object
16 17 18 19 20 |
# File 'lib/generators/pg_insights/install_generator.rb', line 16 def copy_migrations copy_queries_migration copy_health_check_results_migration copy_query_executions_migration end |
#create_initializer ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/pg_insights/install_generator.rb', line 22 def create_initializer initializer_path = File.join(destination_root, "config", "initializers", "pg_insights.rb") if File.exist?(initializer_path) say_status("skipped", "Initializer 'config/initializers/pg_insights.rb' already exists", :yellow) else puts "Creating PgInsights initializer..." create_file "config/initializers/pg_insights.rb", initializer_content end end |
#mount_engine ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/pg_insights/install_generator.rb', line 33 def mount_engine route_to_add = "mount PgInsights::Engine => '/pg_insights'" routes_file = File.join(destination_root, "config", "routes.rb") if File.exist?(routes_file) && File.read(routes_file).include?(route_to_add) say_status("skipped", "Route `#{route_to_add}` already exists in `config/routes.rb`", :yellow) else puts "Mounting PgInsights engine..." route route_to_add end end |
#show_readme ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/generators/pg_insights/install_generator.rb', line 45 def show_readme puts "\nPgInsights has been successfully installed!" puts "" puts "Next steps:" puts "1. Run 'rails db:migrate' to create the necessary tables" puts "2. Review and customize 'config/initializers/pg_insights.rb'" puts "3. Test your setup: rails pg_insights:status" puts "4. Configure background jobs (optional, see initializer comments)" puts "5. Visit '/pg_insights' in your browser to start using the dashboard" puts "" puts "Features available:" puts "• Health Dashboard: '/pg_insights/health' - Monitor database health" puts "• Query Runner: '/pg_insights' - Run SQL queries with charts & EXPLAIN ANALYZE" puts "• Timeline: '/pg_insights/timeline' - Track parameter changes over time" puts "" puts "Useful commands:" puts "• Status check: rails pg_insights:status" puts "• Test setup: rails pg_insights:test_jobs" puts "• Collect snapshot: rails pg_insights:collect_snapshot" puts "• Start snapshots: rails pg_insights:start_snapshots" puts "• Snapshot status: rails pg_insights:snapshot_status" puts "" puts "For development/testing:" puts "• Generate test data: rails pg_insights:seed_timeline" puts "• View all commands: rails -T pg_insights" puts "" puts "Configuration: config/initializers/pg_insights.rb" puts "Documentation: https://github.com/mezbahalam/pg_insights" puts "To uninstall: rails generate pg_insights:clean" end |