commentaries: migrate columns to non-null.
This commit is contained in:
@@ -34,15 +34,15 @@ class ArtistCommentary < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
if params[:original_present] == "yes"
|
if params[:original_present] == "yes"
|
||||||
q = q.where("(original_title is not null and original_title != '') or (original_description is not null and original_description != '')")
|
q = q.where("(original_title != '') or (original_description != '')")
|
||||||
elsif params[:original_present] == "no"
|
elsif params[:original_present] == "no"
|
||||||
q = q.where("(original_title is null or original_title = '') and (original_description is null or original_description = '')")
|
q = q.where("(original_title = '') and (original_description = '')")
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:translated_present] == "yes"
|
if params[:translated_present] == "yes"
|
||||||
q = q.where("(translated_title is not null and translated_title != '') or (translated_description is not null and translated_description != '')")
|
q = q.where("(translated_title != '') or (translated_description != '')")
|
||||||
elsif params[:translated_present] == "no"
|
elsif params[:translated_present] == "no"
|
||||||
q = q.where("(translated_title is null or translated_title = '') and (translated_description is null or translated_description = '')")
|
q = q.where("(translated_title = '') and (translated_description = '')")
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:post_tags_match].present?
|
if params[:post_tags_match].present?
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
class ChangeFieldsToNonNullOnArtistCommentaries < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
ArtistCommentary.without_timeout do
|
||||||
|
change_column_null(:artist_commentaries, :original_title, false, "")
|
||||||
|
change_column_null(:artist_commentaries, :translated_title, false, "")
|
||||||
|
change_column_null(:artist_commentaries, :original_description, false, "")
|
||||||
|
change_column_null(:artist_commentaries, :translated_description, false, "")
|
||||||
|
|
||||||
|
change_column_default(:artist_commentaries, :original_title, "")
|
||||||
|
change_column_default(:artist_commentaries, :translated_title, "")
|
||||||
|
change_column_default(:artist_commentaries, :original_description, "")
|
||||||
|
change_column_default(:artist_commentaries, :translated_description, "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
ArtistCommentary.without_timeout do
|
||||||
|
change_column_null(:artist_commentaries, :original_title, true)
|
||||||
|
change_column_null(:artist_commentaries, :translated_title, true)
|
||||||
|
change_column_null(:artist_commentaries, :original_description, true)
|
||||||
|
change_column_null(:artist_commentaries, :translated_description, true)
|
||||||
|
|
||||||
|
change_column_default(:artist_commentaries, :original_title, nil)
|
||||||
|
change_column_default(:artist_commentaries, :translated_title, nil)
|
||||||
|
change_column_default(:artist_commentaries, :original_description, nil)
|
||||||
|
change_column_default(:artist_commentaries, :translated_description, nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -603,10 +603,10 @@ ALTER SEQUENCE api_keys_id_seq OWNED BY api_keys.id;
|
|||||||
CREATE TABLE artist_commentaries (
|
CREATE TABLE artist_commentaries (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
post_id integer NOT NULL,
|
post_id integer NOT NULL,
|
||||||
original_title text,
|
original_title text DEFAULT ''::text NOT NULL,
|
||||||
original_description text,
|
original_description text DEFAULT ''::text NOT NULL,
|
||||||
translated_title text,
|
translated_title text DEFAULT ''::text NOT NULL,
|
||||||
translated_description text,
|
translated_description text DEFAULT ''::text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone
|
||||||
);
|
);
|
||||||
@@ -7563,3 +7563,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170526183928');
|
|||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20170608043651');
|
INSERT INTO schema_migrations (version) VALUES ('20170608043651');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20170613200356');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user