Class: PgEasyReplicate::CLI
- Inherits:
-
Thor
- Object
- Thor
- PgEasyReplicate::CLI
- Defined in:
- lib/pg_easy_replicate/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply_ddl_change ⇒ Object
- #bootstrap ⇒ Object
- #cleanup ⇒ Object
- #config_check ⇒ Object
- #list_ddl_changes ⇒ Object
- #start_sync ⇒ Object
- #stats ⇒ Object
- #stop_sync ⇒ Object
- #switchover ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
236 237 238 |
# File 'lib/pg_easy_replicate/cli.rb', line 236 def self.exit_on_failure? true end |
Instance Method Details
#apply_ddl_change ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/pg_easy_replicate/cli.rb', line 195 def apply_ddl_change if [:id] PgEasyReplicate::DDLManager.apply_ddl_change( group_name: [:group_name], id: [:id], ) puts "DDL change with ID #{[:id]} applied successfully." else changes = PgEasyReplicate::DDLManager.list_ddl_changes( group_name: [:group_name], ) if changes.empty? puts "No pending DDL changes to apply." return end puts "The following DDL changes will be applied:" changes.each do |change| puts "ID: #{change[:id]}, Type: #{change[:object_type]}, Command: #{change[:ddl_command]}" end puts "" print("Do you want to apply all these changes? (y/n): ") confirmation = $stdin.gets.chomp.downcase if confirmation == "y" PgEasyReplicate::DDLManager.apply_all_ddl_changes( group_name: [:group_name], ) puts "All pending DDL changes applied successfully." else puts "Operation cancelled." end end end |
#bootstrap ⇒ Object
64 65 66 |
# File 'lib/pg_easy_replicate/cli.rb', line 64 def bootstrap PgEasyReplicate.bootstrap() end |
#cleanup ⇒ Object
81 82 83 |
# File 'lib/pg_easy_replicate/cli.rb', line 81 def cleanup PgEasyReplicate.cleanup() end |
#config_check ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pg_easy_replicate/cli.rb', line 33 def config_check PgEasyReplicate.assert_config( special_user_role: [:special_user_role], copy_schema: [:copy_schema], tables: [:tables], exclude_tables: [:exclude_tables], schema_name: [:schema_name], ) puts "✅ Config is looking good." end |
#list_ddl_changes ⇒ Object
176 177 178 179 180 181 182 183 |
# File 'lib/pg_easy_replicate/cli.rb', line 176 def list_ddl_changes changes = PgEasyReplicate::DDLManager.list_ddl_changes( group_name: [:group_name], limit: [:limit], ) puts JSON.pretty_generate(changes) end |
#start_sync ⇒ Object
115 116 117 |
# File 'lib/pg_easy_replicate/cli.rb', line 115 def start_sync PgEasyReplicate::Orchestrate.start_sync() end |
#stats ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/pg_easy_replicate/cli.rb', line 158 def stats if [:watch] PgEasyReplicate::Stats.follow([:group_name]) else PgEasyReplicate::Stats.print([:group_name]) end end |
#stop_sync ⇒ Object
125 126 127 |
# File 'lib/pg_easy_replicate/cli.rb', line 125 def stop_sync PgEasyReplicate::Orchestrate.stop_sync(group_name: [:group_name]) end |
#switchover ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/pg_easy_replicate/cli.rb', line 144 def switchover PgEasyReplicate::Orchestrate.switchover( group_name: [:group_name], lag_delta_size: [:lag_delta_size], skip_vacuum_analyze: [:skip_vacuum_analyze], ) end |
#version ⇒ Object
232 233 234 |
# File 'lib/pg_easy_replicate/cli.rb', line 232 def version puts PgEasyReplicate::VERSION end |