-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split processes' name migration into two
As it won't be possible to start new processes after the column is made NOT NULL and before deploying the code that uses that column.
- Loading branch information
Showing
3 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
class AddNameToProcesses < ActiveRecord::Migration[7.1] | ||
def up | ||
def change | ||
add_column :solid_queue_processes, :name, :string | ||
|
||
SolidQueue::Process.find_each do |process| | ||
process.name ||= [ process.kind.downcase, SecureRandom.hex(10) ].join("-") | ||
process.save! | ||
end | ||
|
||
add_index :solid_queue_processes, [ :name, :supervisor_id ], unique: true | ||
change_column :solid_queue_processes, :name, :string, null: false | ||
end | ||
|
||
def down | ||
remove_index :solid_queue_processes, [ :name, :supervisor_id ] | ||
remove_column :solid_queue_processes, :name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class MakeNameNotNull < ActiveRecord::Migration[7.1] | ||
def up | ||
SolidQueue::Process.where(name: nil).find_each do |process| | ||
process.name ||= [ process.kind.downcase, SecureRandom.hex(10) ].join("-") | ||
process.save! | ||
end | ||
|
||
change_column :solid_queue_processes, :name, :string, null: false | ||
add_index :solid_queue_processes, [ :name, :supervisor_id ], unique: true | ||
end | ||
|
||
def down | ||
remove_index :solid_queue_processes, [ :name, :supervisor_id ] | ||
change_column :solid_queue_processes, :name, :string, null: false | ||
end | ||
end |