Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make several additional columns NOT NULL #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/generators/delayed_job/templates/columns_not_null.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ColumnsNotNull < ActiveRecord::Migration<%= migration_version %>
def change
change_column_null :delayed_jobs, :run_at, false
change_column_null :delayed_jobs, :queue, false
change_column_null :delayed_jobs, :created_at, false
change_column_null :delayed_jobs, :updated_at, false
end
end
6 changes: 3 additions & 3 deletions lib/generators/delayed_job/templates/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ def self.up
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
table.text :handler, null: false # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :run_at, null: false # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
table.string :locked_by # Who is working on this object (if locked)
table.string :queue # The name of the queue this job is in
table.timestamps null: true
table.string :queue, null: false # The name of the queue this job is in
table.timestamps
end

add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
Expand Down
5 changes: 5 additions & 0 deletions lib/generators/delayed_job/upgrade_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def create_migration_file
"db/migrate/add_queue_to_delayed_jobs.rb",
migration_version: migration_version
)
migration_template(
"columns_not_null.rb",
"db/migrate/columns_not_null.rb",
migration_version: migration_version
)
end
end
end