fix migration for circleci

This commit is contained in:
Albert Yi
2018-12-06 10:31:24 -08:00
parent 3893926048
commit 79dfa6c28f
3 changed files with 12 additions and 9 deletions

View File

@@ -1,8 +1,10 @@
class ChangeDescendantNamesToArrayOnTagImplications < ActiveRecord::Migration[5.2]
def up
TagImplication.without_timeout do
change_column_default :tag_implications, :descendant_names, from: '', to: nil
change_column :tag_implications, :descendant_names, "text[]", using: "string_to_array(descendant_names, ' ')::text[]", default: "{}"
add_column :tag_implications, :descendant_names_array, "text[]", default: "{}"
execute "update tag_implications set descendant_names_array = string_to_array(descendant_names, ' ')::text[]"
remove_column :tag_implications, :descendant_names
rename_column :tag_implications, :descendant_names_array, :descendant_names
end
end

View File

@@ -1,11 +1,14 @@
class ChangeStringsToArraysOnArtistVersions < ActiveRecord::Migration[5.2]
def up
ArtistVersion.without_timeout do
change_column_default :artist_versions, :other_names, from: '', to: nil
change_column :artist_versions, :other_names, "text[]", using: "array_remove(regexp_split_to_array(other_names, '\\s+'), '')", default: "{}"
add_column :artist_versions, :other_names_array, "text[]", default: "{}"
execute "update artist_versions set other_names_array = array_remove(regexp_split_to_array(other_names, '\\s+'), '')"
remove_column :artist_versions, :other_names
rename_column :artist_versions, :other_names_array, :other_names
change_column :artist_versions, :url_string, "text[]", using: "array_remove(regexp_split_to_array(url_string, '\\s+'), '')", default: "{}"
rename_column :artist_versions, :url_string, :urls
add_column :artist_versions, :urls, "text[]", default: "{}"
execute "update artist_versions set urls = array_remove(regexp_split_to_array(url_string, '\\s+'), '')"
remove_column :artist_versions, :url_string
end
end

View File

@@ -65,7 +65,6 @@ class ArtistUrlTest < ActiveSupport::TestCase
setup do
@urls = [
FactoryBot.create(:artist_url, url: "https://www.artstation.com/koyorin"),
FactoryBot.create(:artist_url, url: "https://www.artstation.com/artist/koyorin"),
FactoryBot.create(:artist_url, url: "https://koyorin.artstation.com"),
FactoryBot.create(:artist_url, url: "https://www.artstation.com/artwork/04XA4")
]
@@ -74,8 +73,7 @@ class ArtistUrlTest < ActiveSupport::TestCase
should "normalize" do
assert_equal("http://www.artstation.com/koyorin/", @urls[0].normalized_url)
assert_equal("http://www.artstation.com/koyorin/", @urls[1].normalized_url)
assert_equal("http://www.artstation.com/koyorin/", @urls[2].normalized_url)
assert_equal("http://www.artstation.com/jeyrain/", @urls[3].normalized_url)
assert_equal("http://www.artstation.com/jeyrain/", @urls[2].normalized_url)
end
end