Class: SolidQueueGuard::Schema::SolidQueueTables Private
- Inherits:
-
Object
- Object
- SolidQueueGuard::Schema::SolidQueueTables
- Defined in:
- lib/solid_queue_guard/schema/solid_queue_tables.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- SCHEMA_FILES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[ db/queue_schema.rb db/schema.rb db/structure.sql ].freeze
- RUBY_CREATE_TABLE_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/ create_table \s+ (?: ["'](?<quoted>solid_queue_[a-z_]+)["'] | :(?<symbol>solid_queue_[a-z_]+) ) /ix- SQL_CREATE_TABLE_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/ CREATE \ TABLE (?: \ IF \ NOT \ EXISTS )? \s+ (?:[\w.]+\.)? (?: "(?<quoted>solid_queue_[a-z_]+)" | (?<unquoted>solid_queue_[a-z_]+) ) /ix
Class Method Summary collapse
- .default_required_tables ⇒ Object private
- .detected_tables(rails_root: Rails.root) ⇒ Object private
- .missing_tables(rails_root: Rails.root) ⇒ Object private
- .required_tables ⇒ Object private
- .tables_from_gem_template ⇒ Object private
Class Method Details
.default_required_tables ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/solid_queue_guard/schema/solid_queue_tables.rb', line 82 def default_required_tables %w[ solid_queue_blocked_executions solid_queue_claimed_executions solid_queue_failed_executions solid_queue_jobs solid_queue_pauses solid_queue_processes solid_queue_ready_executions solid_queue_recurring_executions solid_queue_recurring_tasks solid_queue_scheduled_executions solid_queue_semaphores ].freeze end |
.detected_tables(rails_root: Rails.root) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/solid_queue_guard/schema/solid_queue_tables.rb', line 40 def detected_tables(rails_root: Rails.root) file_tables = {} tables = Set.new SCHEMA_FILES.each do |relative_path| path = rails_root.join(relative_path) next unless path.exist? tables_in_file = parse_file(path) next if tables_in_file.empty? file_tables[relative_path] = tables_in_file.sort tables.merge(tables_in_file) end database_tables = tables_in_queue_database tables.merge(database_tables) { tables: tables.sort, file_tables: file_tables, database_tables: database_tables.sort } end |
.missing_tables(rails_root: Rails.root) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/solid_queue_guard/schema/solid_queue_tables.rb', line 65 def missing_tables(rails_root: Rails.root) required_tables - detected_tables(rails_root: rails_root)[:tables] end |
.required_tables ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/solid_queue_guard/schema/solid_queue_tables.rb', line 36 def required_tables @required_tables ||= tables_from_gem_template || default_required_tables end |
.tables_from_gem_template ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/solid_queue_guard/schema/solid_queue_tables.rb', line 69 def tables_from_gem_template spec = Gem.loaded_specs['solid_queue'] return nil unless spec template = File.join( spec.full_gem_path, 'lib/generators/solid_queue/install/templates/db/queue_schema.rb' ) return nil unless File.exist?(template) parse_ruby_schema(File.read(template)) end |