Skip to content

Commit

Permalink
Update migrations for Rubocop
Browse files Browse the repository at this point in the history
Not sure why this didn’t crop up locally, but CI’s definitely not happy
without these changes.
  • Loading branch information
pat committed Jul 23, 2024
1 parent fd23aad commit afe4623
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
16 changes: 10 additions & 6 deletions db/migrate/20200524062158_relax_provider_columns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

class RelaxProviderColumns < ActiveRecord::Migration[6.0]
def up
change_column_null :fans, :provider, true
change_column_null :fans, :provider_identity, true
change_table :fans, :bulk => true do |t|
t.change_null :provider, true
t.change_null :provider_identity, true

change_column_null :fans, :email, false
t.change_null :email, false
end
end

def down
change_column_null :fans, :provider, false
change_column_null :fans, :provider_identity, false
change_table :fans, :bulk => true do |t|
t.change_null :provider, false
t.change_null :provider_identity, false

change_column_null :fans, :email, true
t.change_null :email, true
end
end
end
16 changes: 10 additions & 6 deletions db/migrate/20200824120413_split_album_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
class SplitAlbumUrls < ActiveRecord::Migration[6.0]
# rubocop:disable Metrics/MethodLength
def up
rename_column :albums, :url, :last_fm_url
change_column_null :albums, :last_fm_url, true
add_column :albums, :spotify_url, :string
change_table :albums, :bulk => true do |t|
t.rename_column :url, :last_fm_url
t.change_null :last_fm_url, true
t.add_column :spotify_url, :string
end

execute <<~SQL.squish
UPDATE albums
Expand All @@ -26,8 +28,10 @@ def down
WHERE spotify_url IS NOT NULL
SQL

remove_column :albums, :spotify_url
change_column_null :albums, :last_fm_url, false
rename_column :albums, :last_fm_url, :url
change_table :albums, :bulk => true do |t|
t.remove_column :spotify_url
t.change_null :last_fm_url, false
t.rename_column :last_fm_url, :url
end
end
end
16 changes: 10 additions & 6 deletions db/migrate/20200824121128_split_artist_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
class SplitArtistUrls < ActiveRecord::Migration[6.0]
# rubocop:disable Metrics/MethodLength
def up
rename_column :artists, :url, :last_fm_url
change_column_null :artists, :last_fm_url, true
add_column :artists, :spotify_url, :string
change_table :artists, :bulk => true do |t|
t.rename_column :url, :last_fm_url
t.change_null :last_fm_url, true
t.add_column :spotify_url, :string
end

execute <<~SQL.squish
UPDATE artists
Expand All @@ -26,8 +28,10 @@ def down
WHERE spotify_url IS NOT NULL
SQL

remove_column :artists, :spotify_url
change_column_null :artists, :last_fm_url, false
rename_column :artists, :last_fm_url, :url
change_table :artists, :bulk => true do |t|
t.remove_column :spotify_url
t.change_null :last_fm_url, false
t.rename_column :last_fm_url, :url
end
end
end

0 comments on commit afe4623

Please sign in to comment.