Module: PgCron
- Defined in:
- lib/pg_cron.rb,
lib/pg_cron/job.rb,
lib/pg_cron/railtie.rb,
lib/pg_cron/version.rb,
lib/pg_cron/definition.rb,
lib/pg_cron/statements.rb,
lib/pg_cron/configuration.rb,
lib/pg_cron/schema_dumper.rb,
lib/pg_cron/command_recorder.rb,
lib/pg_cron/adapters/postgres.rb,
lib/generators/pg_cron/name_helper.rb,
lib/pg_cron/adapters/postgres/jobs.rb,
lib/generators/pg_cron/version_helper.rb,
lib/generators/pg_cron/migration_helper.rb,
lib/generators/pg_cron/job/job_generator.rb,
lib/pg_cron/adapters/postgres/connection.rb,
lib/pg_cron/adapters/postgres/query_executor.rb
Defined Under Namespace
Modules: Adapters, CommandRecorder, Generators, SchemaDumper, Statements Classes: Configuration, Definition, Job, Railtie
Constant Summary collapse
- VERSION =
"2.0.0"
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.connection ⇒ Object
The adapter cron statements run through.
- .database ⇒ Object
- .load ⇒ Object
Class Method Details
.configuration ⇒ Object
26 27 28 |
# File 'lib/pg_cron/configuration.rb', line 26 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
30 31 32 |
# File 'lib/pg_cron/configuration.rb', line 30 def self.configure yield configuration end |
.connection ⇒ Object
The adapter cron statements run through.
Was a SECOND connection, opened via ActiveRecord::Base.postgresql_connection
against a database named postgres, and reconnected by hand. Two problems:
postgresql_connection was removed in Rails 8, and the separate database was
wrong for this setup anyway — cron.job lives in whatever cron.database_name
points at, which is the application's own database, so the application's own
connection is the one that can see it.
It also has to be that connection for a second reason: pg_cron puts row-level security on cron.job filtering by username, so jobs created on a different connection as a different role are invisible to the app and to the schema dumper.
41 42 43 |
# File 'lib/pg_cron.rb', line 41 def self.connection configuration.adapter end |
.database ⇒ Object
34 35 36 |
# File 'lib/pg_cron/configuration.rb', line 34 def self.database configuration.adapter end |
.load ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pg_cron.rb', line 15 def self.load # Make PgCron::Statements available during migrations ActiveRecord::ConnectionAdapters::AbstractAdapter.include PgCron::Statements # Make PgCron::Statements reversible for migration rollbacks ActiveRecord::Migration::CommandRecorder.include PgCron::CommandRecorder # Teach the schema dumper about cron jobs. Without this db/schema.rb carries # every table and none of the schedules, so a db:schema:load database comes # up silently missing them. ActiveRecord::SchemaDumper.prepend PgCron::SchemaDumper end |