-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added
download_filename_type
value for old data
- Loading branch information
Showing
3 changed files
with
17 additions
and
3 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
17 changes: 15 additions & 2 deletions
17
db/migrate/20241127143631_add_download_file_type_to_channel.rb
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,7 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddDownloadFileTypeToChannel < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :channels, :download_filename_type, :string, null: true | ||
def up | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.column_exists?(:channels, :download_filename_type) | ||
|
||
add_column :channels, :download_filename_type, :string | ||
|
||
Channel.find_each do |channel| | ||
# 默认值取自 `Channel.DEFAULT_DOWNLOAD_FILENAME_TYPE` | ||
channel.update!(download_filename_type: 'version_datetime') if channel.download_filename_type.nil? | ||
end | ||
end | ||
|
||
def down | ||
remove_column :channels, :download_filename_type | ||
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