pgbus 0.6.7 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/pgbus/dashboard_controller.rb +4 -0
  3. data/app/controllers/pgbus/queues_controller.rb +1 -0
  4. data/app/views/pgbus/dashboard/_queue_health.html.erb +78 -0
  5. data/app/views/pgbus/dashboard/show.html.erb +2 -0
  6. data/app/views/pgbus/queues/show.html.erb +37 -0
  7. data/config/locales/da.yml +35 -4
  8. data/config/locales/de.yml +35 -4
  9. data/config/locales/en.yml +35 -4
  10. data/config/locales/es.yml +35 -4
  11. data/config/locales/fi.yml +35 -4
  12. data/config/locales/fr.yml +35 -4
  13. data/config/locales/it.yml +35 -4
  14. data/config/locales/ja.yml +35 -4
  15. data/config/locales/nb.yml +35 -4
  16. data/config/locales/nl.yml +35 -4
  17. data/config/locales/pt.yml +35 -4
  18. data/config/locales/sv.yml +35 -4
  19. data/lib/generators/pgbus/add_failed_events_index_generator.rb +4 -11
  20. data/lib/generators/pgbus/add_job_locks_generator.rb +4 -11
  21. data/lib/generators/pgbus/add_job_stats_generator.rb +4 -11
  22. data/lib/generators/pgbus/add_job_stats_latency_generator.rb +4 -11
  23. data/lib/generators/pgbus/add_job_stats_queue_index_generator.rb +4 -11
  24. data/lib/generators/pgbus/add_outbox_generator.rb +4 -11
  25. data/lib/generators/pgbus/add_presence_generator.rb +4 -11
  26. data/lib/generators/pgbus/add_queue_states_generator.rb +4 -11
  27. data/lib/generators/pgbus/add_recurring_generator.rb +4 -11
  28. data/lib/generators/pgbus/add_stream_stats_generator.rb +4 -11
  29. data/lib/generators/pgbus/install_generator.rb +4 -11
  30. data/lib/generators/pgbus/migrate_job_locks_generator.rb +4 -11
  31. data/lib/generators/pgbus/migration_path.rb +28 -0
  32. data/lib/generators/pgbus/templates/migration.rb.erb +6 -0
  33. data/lib/generators/pgbus/templates/tune_autovacuum.rb.erb +38 -0
  34. data/lib/generators/pgbus/tune_autovacuum_generator.rb +48 -0
  35. data/lib/generators/pgbus/upgrade_pgmq_generator.rb +4 -11
  36. data/lib/pgbus/autovacuum_tuning.rb +93 -0
  37. data/lib/pgbus/client.rb +13 -1
  38. data/lib/pgbus/engine.rb +1 -0
  39. data/lib/pgbus/generators/migration_detector.rb +38 -3
  40. data/lib/pgbus/version.rb +1 -1
  41. data/lib/pgbus/web/data_source.rb +133 -1
  42. data/lib/pgbus/web/metrics_serializer.rb +71 -2
  43. data/lib/tasks/pgbus_autovacuum.rake +40 -0
  44. metadata +7 -1
@@ -10,6 +10,28 @@ nb:
10
10
  pid: PID
11
11
  status: Status
12
12
  title: Aktive prosesser
13
+ queue_health:
14
+ dead_tuples: Døde tupler
15
+ headers:
16
+ bloat: Bloat
17
+ dead: Døde
18
+ kind: Type
19
+ last_vacuum: Siste Vacuum
20
+ live: Levende
21
+ table: Tabell
22
+ kinds:
23
+ archive: Arkiv
24
+ queue: Kø
25
+ last_vacuum: Siste Vacuum
26
+ live: Levende
27
+ mvcc_horizon: MVCC-horisont
28
+ oldest_open_txn: Eldste åpne transaksjon
29
+ oldest_vacuum_ago: Eldste tabell-vacuum
30
+ tables_need_vacuum:
31
+ one: "%{count} tabell trenger vacuum"
32
+ other: "%{count} tabeller trenger vacuum"
33
+ title: Køhelse
34
+ worst_bloat: Verste Bloat
13
35
  queues_table:
14
36
  empty: Ingen køer funnet
15
37
  headers:
@@ -337,6 +359,15 @@ nb:
337
359
  resume: Gjenoppta
338
360
  retry: Prøv igjen
339
361
  retry_confirm: Tilbakestill synlighetstidsavbrudd og prøv igjen?
362
+ table_health:
363
+ headers:
364
+ bloat: Bloat
365
+ dead: Døde
366
+ last_vacuum: Siste Vacuum
367
+ live: Levende
368
+ table: Tabell
369
+ oldest_txn: 'Eldste åpne transaksjon:'
370
+ title: Tabellhelse
340
371
  total: 'Totalt:'
341
372
  visible: 'Synlig:'
342
373
  recurring_tasks:
@@ -345,10 +376,6 @@ nb:
345
376
  one: "%{count} oppgave konfigurert"
346
377
  other: "%{count} oppgaver konfigurert"
347
378
  title: Gjentakende oppgaver
348
- toggle:
349
- disabled: Oppgave deaktivert
350
- enabled: Oppgave aktivert
351
- failed: Kunne ikke endre oppgave
352
379
  show:
353
380
  back: Tilbake
354
381
  configuration: Konfigurasjon
@@ -392,3 +419,7 @@ nb:
392
419
  task: Oppgave
393
420
  never: Aldri
394
421
  run_now: Kjør nå
422
+ toggle:
423
+ disabled: Oppgave deaktivert
424
+ enabled: Oppgave aktivert
425
+ failed: Kunne ikke endre oppgave
@@ -10,6 +10,28 @@ nl:
10
10
  pid: PID
11
11
  status: Status
12
12
  title: Actieve processen
13
+ queue_health:
14
+ dead_tuples: Dode tupels
15
+ headers:
16
+ bloat: Bloat
17
+ dead: Dood
18
+ kind: Type
19
+ last_vacuum: Laatste Vacuum
20
+ live: Actief
21
+ table: Tabel
22
+ kinds:
23
+ archive: Archief
24
+ queue: Wachtrij
25
+ last_vacuum: Laatste Vacuum
26
+ live: Actief
27
+ mvcc_horizon: MVCC-horizon
28
+ oldest_open_txn: Oudste open transactie
29
+ oldest_vacuum_ago: Oudste tabel-vacuum
30
+ tables_need_vacuum:
31
+ one: "%{count} tabel heeft vacuum nodig"
32
+ other: "%{count} tabellen hebben vacuum nodig"
33
+ title: Wachtrijgezondheid
34
+ worst_bloat: Ergste Bloat
13
35
  queues_table:
14
36
  empty: Geen wachtrijen gevonden
15
37
  headers:
@@ -337,6 +359,15 @@ nl:
337
359
  resume: Hervatten
338
360
  retry: Opnieuw proberen
339
361
  retry_confirm: Zichtbaarheidstimeout resetten en opnieuw proberen?
362
+ table_health:
363
+ headers:
364
+ bloat: Bloat
365
+ dead: Dood
366
+ last_vacuum: Laatste Vacuum
367
+ live: Actief
368
+ table: Tabel
369
+ oldest_txn: 'Oudste open transactie:'
370
+ title: Tabelgezondheid
340
371
  total: 'Totaal:'
341
372
  visible: 'Zichtbaar:'
342
373
  recurring_tasks:
@@ -345,10 +376,6 @@ nl:
345
376
  one: "%{count} taak geconfigureerd"
346
377
  other: "%{count} taken geconfigureerd"
347
378
  title: Terugkerende taken
348
- toggle:
349
- disabled: Taak uitgeschakeld
350
- enabled: Taak ingeschakeld
351
- failed: Kon taak niet omschakelen
352
379
  show:
353
380
  back: Terug
354
381
  configuration: Configuratie
@@ -392,3 +419,7 @@ nl:
392
419
  task: Taak
393
420
  never: Nooit
394
421
  run_now: Nu uitvoeren
422
+ toggle:
423
+ disabled: Taak uitgeschakeld
424
+ enabled: Taak ingeschakeld
425
+ failed: Kon taak niet omschakelen
@@ -10,6 +10,28 @@ pt:
10
10
  pid: PID
11
11
  status: Status
12
12
  title: Processos Ativos
13
+ queue_health:
14
+ dead_tuples: Tuplas mortas
15
+ headers:
16
+ bloat: Bloat
17
+ dead: Mortas
18
+ kind: Tipo
19
+ last_vacuum: Último Vacuum
20
+ live: Ativas
21
+ table: Tabela
22
+ kinds:
23
+ archive: Arquivo
24
+ queue: Fila
25
+ last_vacuum: Último Vacuum
26
+ live: Ativas
27
+ mvcc_horizon: Horizonte MVCC
28
+ oldest_open_txn: Transação aberta mais antiga
29
+ oldest_vacuum_ago: Vacuum de tabela mais antigo
30
+ tables_need_vacuum:
31
+ one: "%{count} tabela precisa de vacuum"
32
+ other: "%{count} tabelas precisam de vacuum"
33
+ title: Saúde das Filas
34
+ worst_bloat: Pior Bloat
13
35
  queues_table:
14
36
  empty: Nenhuma fila encontrada
15
37
  headers:
@@ -337,6 +359,15 @@ pt:
337
359
  resume: Retomar
338
360
  retry: Tentar novamente
339
361
  retry_confirm: Redefinir tempo de visibilidade e tentar novamente?
362
+ table_health:
363
+ headers:
364
+ bloat: Bloat
365
+ dead: Mortas
366
+ last_vacuum: Último Vacuum
367
+ live: Ativas
368
+ table: Tabela
369
+ oldest_txn: 'Transação aberta mais antiga:'
370
+ title: Saúde das Tabelas
340
371
  total: 'Total:'
341
372
  visible: 'Visível:'
342
373
  recurring_tasks:
@@ -345,10 +376,6 @@ pt:
345
376
  one: "%{count} tarefa configurada"
346
377
  other: "%{count} tarefas configuradas"
347
378
  title: Tarefas Recorrentes
348
- toggle:
349
- disabled: Tarefa desativada
350
- enabled: Tarefa ativada
351
- failed: Falha ao alternar tarefa
352
379
  show:
353
380
  back: Voltar
354
381
  configuration: Configuração
@@ -392,3 +419,7 @@ pt:
392
419
  task: Tarefa
393
420
  never: Nunca
394
421
  run_now: Executar Agora
422
+ toggle:
423
+ disabled: Tarefa desativada
424
+ enabled: Tarefa ativada
425
+ failed: Falha ao alternar tarefa
@@ -10,6 +10,28 @@ sv:
10
10
  pid: PID
11
11
  status: Status
12
12
  title: Aktiva processer
13
+ queue_health:
14
+ dead_tuples: Döda tuplar
15
+ headers:
16
+ bloat: Bloat
17
+ dead: Döda
18
+ kind: Typ
19
+ last_vacuum: Senaste Vacuum
20
+ live: Levande
21
+ table: Tabell
22
+ kinds:
23
+ archive: Arkiv
24
+ queue: Kö
25
+ last_vacuum: Senaste Vacuum
26
+ live: Levande
27
+ mvcc_horizon: MVCC-horisont
28
+ oldest_open_txn: Äldsta öppna transaktion
29
+ oldest_vacuum_ago: Äldsta tabell-vacuum
30
+ tables_need_vacuum:
31
+ one: "%{count} tabell behöver vacuum"
32
+ other: "%{count} tabeller behöver vacuum"
33
+ title: Köhälsa
34
+ worst_bloat: Värsta Bloat
13
35
  queues_table:
14
36
  empty: Inga köer hittades
15
37
  headers:
@@ -337,6 +359,15 @@ sv:
337
359
  resume: Återuppta
338
360
  retry: Försök igen
339
361
  retry_confirm: Återställ synlighetstimeout och försök igen?
362
+ table_health:
363
+ headers:
364
+ bloat: Bloat
365
+ dead: Döda
366
+ last_vacuum: Senaste Vacuum
367
+ live: Levande
368
+ table: Tabell
369
+ oldest_txn: 'Äldsta öppna transaktion:'
370
+ title: Tabellhälsa
340
371
  total: 'Totalt:'
341
372
  visible: 'Synliga:'
342
373
  recurring_tasks:
@@ -345,10 +376,6 @@ sv:
345
376
  one: "%{count} uppgift konfigurerad"
346
377
  other: "%{count} uppgifter konfigurerade"
347
378
  title: Återkommande uppgifter
348
- toggle:
349
- disabled: Uppgift inaktiverad
350
- enabled: Uppgift aktiverad
351
- failed: Kunde inte ändra uppgift
352
379
  show:
353
380
  back: Tillbaka
354
381
  configuration: Konfiguration
@@ -392,3 +419,7 @@ sv:
392
419
  task: Uppgift
393
420
  never: Aldrig
394
421
  run_now: Kör nu
422
+ toggle:
423
+ disabled: Uppgift inaktiverad
424
+ enabled: Uppgift aktiverad
425
+ failed: Kunde inte ändra uppgift
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddFailedEventsIndexGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_failed_events_unique_index.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_failed_events_unique_index.rb"
24
- else
25
- migration_template "add_failed_events_unique_index.rb.erb",
26
- "db/migrate/add_pgbus_failed_events_unique_index.rb"
27
- end
23
+ migration_template "add_failed_events_unique_index.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_failed_events_unique_index.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -42,10 +39,6 @@ module Pgbus
42
39
  def migration_version
43
40
  "[#{ActiveRecord::Migration.current_version}]"
44
41
  end
45
-
46
- def separate_database?
47
- options[:database].present?
48
- end
49
42
  end
50
43
  end
51
44
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddJobLocksGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_job_locks.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_job_locks.rb"
24
- else
25
- migration_template "add_job_locks.rb.erb",
26
- "db/migrate/add_pgbus_job_locks.rb"
27
- end
23
+ migration_template "add_job_locks.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_job_locks.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -43,10 +40,6 @@ module Pgbus
43
40
  def migration_version
44
41
  "[#{ActiveRecord::Migration.current_version}]"
45
42
  end
46
-
47
- def separate_database?
48
- options[:database].present?
49
- end
50
43
  end
51
44
  end
52
45
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddJobStatsGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_job_stats.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_job_stats.rb"
24
- else
25
- migration_template "add_job_stats.rb.erb",
26
- "db/migrate/add_pgbus_job_stats.rb"
27
- end
23
+ migration_template "add_job_stats.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_job_stats.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -43,10 +40,6 @@ module Pgbus
43
40
  def migration_version
44
41
  "[#{ActiveRecord::Migration.current_version}]"
45
42
  end
46
-
47
- def separate_database?
48
- options[:database].present?
49
- end
50
43
  end
51
44
  end
52
45
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddJobStatsLatencyGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_job_stats_latency.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_job_stats_latency.rb"
24
- else
25
- migration_template "add_job_stats_latency.rb.erb",
26
- "db/migrate/add_pgbus_job_stats_latency.rb"
27
- end
23
+ migration_template "add_job_stats_latency.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_job_stats_latency.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -43,10 +40,6 @@ module Pgbus
43
40
  def migration_version
44
41
  "[#{ActiveRecord::Migration.current_version}]"
45
42
  end
46
-
47
- def separate_database?
48
- options[:database].present?
49
- end
50
43
  end
51
44
  end
52
45
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddJobStatsQueueIndexGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_job_stats_queue_index.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_job_stats_queue_index.rb"
24
- else
25
- migration_template "add_job_stats_queue_index.rb.erb",
26
- "db/migrate/add_pgbus_job_stats_queue_index.rb"
27
- end
23
+ migration_template "add_job_stats_queue_index.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_job_stats_queue_index.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -44,10 +41,6 @@ module Pgbus
44
41
  def migration_version
45
42
  "[#{ActiveRecord::Migration.current_version}]"
46
43
  end
47
-
48
- def separate_database?
49
- options[:database].present?
50
- end
51
44
  end
52
45
  end
53
46
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddOutboxGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_outbox.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_outbox.rb"
24
- else
25
- migration_template "add_outbox.rb.erb",
26
- "db/migrate/add_pgbus_outbox.rb"
27
- end
23
+ migration_template "add_outbox.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_outbox.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -43,10 +40,6 @@ module Pgbus
43
40
  def migration_version
44
41
  "[#{ActiveRecord::Migration.current_version}]"
45
42
  end
46
-
47
- def separate_database?
48
- options[:database].present?
49
- end
50
43
  end
51
44
  end
52
45
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddPresenceGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_presence.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_presence.rb"
24
- else
25
- migration_template "add_presence.rb.erb",
26
- "db/migrate/add_pgbus_presence.rb"
27
- end
23
+ migration_template "add_presence.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_presence.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -46,10 +43,6 @@ module Pgbus
46
43
  def migration_version
47
44
  "[#{ActiveRecord::Migration.current_version}]"
48
45
  end
49
-
50
- def separate_database?
51
- options[:database].present?
52
- end
53
46
  end
54
47
  end
55
48
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddQueueStatesGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_queue_states.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_queue_states.rb"
24
- else
25
- migration_template "add_queue_states.rb.erb",
26
- "db/migrate/add_pgbus_queue_states.rb"
27
- end
23
+ migration_template "add_queue_states.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_queue_states.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -42,10 +39,6 @@ module Pgbus
42
39
  def migration_version
43
40
  "[#{ActiveRecord::Migration.current_version}]"
44
41
  end
45
-
46
- def separate_database?
47
- options[:database].present?
48
- end
49
42
  end
50
43
  end
51
44
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddRecurringGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_recurring_tables.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_recurring_tables.rb"
24
- else
25
- migration_template "add_recurring_tables.rb.erb",
26
- "db/migrate/add_pgbus_recurring_tables.rb"
27
- end
23
+ migration_template "add_recurring_tables.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_recurring_tables.rb")
28
25
  end
29
26
 
30
27
  def create_recurring_config
@@ -47,10 +44,6 @@ module Pgbus
47
44
  def migration_version
48
45
  "[#{ActiveRecord::Migration.current_version}]"
49
46
  end
50
-
51
- def separate_database?
52
- options[:database].present?
53
- end
54
47
  end
55
48
  end
56
49
  end
@@ -2,11 +2,13 @@
2
2
 
3
3
  require "rails/generators"
4
4
  require "rails/generators/active_record"
5
+ require_relative "migration_path"
5
6
 
6
7
  module Pgbus
7
8
  module Generators
8
9
  class AddStreamStatsGenerator < Rails::Generators::Base
9
10
  include ActiveRecord::Generators::Migration
11
+ include MigrationPath
10
12
 
11
13
  source_root File.expand_path("templates", __dir__)
12
14
 
@@ -18,13 +20,8 @@ module Pgbus
18
20
  desc: "Use a separate database for pgbus tables (e.g. --database=pgbus)"
19
21
 
20
22
  def create_migration_file
21
- if separate_database?
22
- migration_template "add_stream_stats.rb.erb",
23
- "db/pgbus_migrate/add_pgbus_stream_stats.rb"
24
- else
25
- migration_template "add_stream_stats.rb.erb",
26
- "db/migrate/add_pgbus_stream_stats.rb"
27
- end
23
+ migration_template "add_stream_stats.rb.erb",
24
+ File.join(pgbus_migrate_path, "add_pgbus_stream_stats.rb")
28
25
  end
29
26
 
30
27
  def display_post_install
@@ -45,10 +42,6 @@ module Pgbus
45
42
  def migration_version
46
43
  "[#{ActiveRecord::Migration.current_version}]"
47
44
  end
48
-
49
- def separate_database?
50
- options[:database].present?
51
- end
52
45
  end
53
46
  end
54
47
  end