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
- #notify ⇒ Object
- #start_sync ⇒ Object
- #stats ⇒ Object
- #stop_sync ⇒ Object
- #switchover ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
271 272 273 |
# File 'lib/pg_easy_replicate/cli.rb', line 271 def self.exit_on_failure? true end |
Instance Method Details
#apply_ddl_change ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/pg_easy_replicate/cli.rb', line 230 def apply_ddl_change if [:id] PgEasyReplicate::DDLManager.apply_ddl_change( group_name: [:group_name], id: [:id], ) puts "DDL change with ID #{options[: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
86 87 88 |
# File 'lib/pg_easy_replicate/cli.rb', line 86 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
211 212 213 214 215 216 217 218 |
# File 'lib/pg_easy_replicate/cli.rb', line 211 def list_ddl_changes changes = PgEasyReplicate::DDLManager.list_ddl_changes( group_name: [:group_name], limit: [:limit], ) puts JSON.pretty_generate(changes) end |
#notify ⇒ Object
192 193 194 195 196 197 198 199 |
# File 'lib/pg_easy_replicate/cli.rb', line 192 def notify PgEasyReplicate::Stats.notify( [:group_name], [:url], [:frequency], [:timeout], ) end |
#start_sync ⇒ Object
120 121 122 |
# File 'lib/pg_easy_replicate/cli.rb', line 120 def start_sync PgEasyReplicate::Orchestrate.start_sync() end |
#stats ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/pg_easy_replicate/cli.rb', line 163 def stats if [:watch] PgEasyReplicate::Stats.follow([:group_name]) else PgEasyReplicate::Stats.print([:group_name]) end end |
#stop_sync ⇒ Object
130 131 132 |
# File 'lib/pg_easy_replicate/cli.rb', line 130 def stop_sync PgEasyReplicate::Orchestrate.stop_sync(group_name: [:group_name]) end |
#switchover ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/pg_easy_replicate/cli.rb', line 149 def switchover PgEasyReplicate::Orchestrate.switchover( group_name: [:group_name], lag_delta_size: [:lag_delta_size], skip_vacuum_analyze: [:skip_vacuum_analyze], ) end |
#version ⇒ Object
267 268 269 |
# File 'lib/pg_easy_replicate/cli.rb', line 267 def version puts PgEasyReplicate::VERSION end |