Class: RailsPulse::Generators::ConvertToMigrationsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RailsPulse::Generators::ConvertToMigrationsGenerator
show all
- Includes:
- Rails::Generators::Migration, BaseMethods
- Defined in:
- lib/generators/rails_pulse/convert_to_migrations_generator.rb
Constant Summary
Constants included
from BaseMethods
BaseMethods::RAILS_PULSE_TABLES
Instance Method Summary
collapse
included
Instance Method Details
#check_schema_file ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/generators/rails_pulse/convert_to_migrations_generator.rb', line 13
def check_schema_file
schema_path = File.join(root_path, "db/rails_pulse_schema.rb")
unless File.exist?(schema_path)
say "No db/rails_pulse_schema.rb file found. Run 'rails generate rails_pulse:install' first.", :red
exit 1
end
if rails_pulse_tables_exist?
say "Rails Pulse tables already exist. No conversion needed.", :yellow
say "Use 'rails generate rails_pulse:upgrade' to update existing installation.", :blue
exit 0
end
end
|
#create_conversion_migration ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/generators/rails_pulse/convert_to_migrations_generator.rb', line 28
def create_conversion_migration
say "Converting db/rails_pulse_schema.rb to migration...", :green
migration_template(
"migrations/install_rails_pulse_tables.rb",
"db/migrate/install_rails_pulse_tables.rb"
)
end
|
#display_completion_message ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/generators/rails_pulse/convert_to_migrations_generator.rb', line 37
def display_completion_message
say <<~MESSAGE
Conversion complete!
Next steps:
1. Run: rails db:migrate
2. Restart your Rails server
The schema file db/rails_pulse_schema.rb remains as your single source of truth.
Future Rails Pulse updates will come as regular migrations in db/migrate/
MESSAGE
end
|