From 6ca01334af266cc316893be4be39feedb37d1235 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 17 Oct 2014 18:08:00 -0500 Subject: [PATCH] Fix frame data records being created for non-ugoira posts. * Prevent non-ugoira posts from getting dummy frame data records with all the columns set to null. * Make `data` and `content_type` columns NOT NULL, since they should always be present. * Remove the timestamps while we're at it, since they don't seem necessary for anything. --- app/models/upload.rb | 2 +- db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb | 9 +++++++++ db/structure.sql | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb diff --git a/app/models/upload.rb b/app/models/upload.rb index 99caf8deb..692c8e731 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -112,7 +112,7 @@ class Upload < ActiveRecord::Base post.distribute_files if post.save CurrentUser.increment!(:post_upload_count) - ugoira_service.process(post) + ugoira_service.process(post) if is_ugoira? update_attributes(:status => "completed", :post_id => post.id) else update_attribute(:status, "error: " + post.errors.full_messages.join(", ")) diff --git a/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb b/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb new file mode 100644 index 000000000..9e6d48eba --- /dev/null +++ b/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb @@ -0,0 +1,9 @@ +class FixPixivUgoiraFrameData < ActiveRecord::Migration + def change + change_table :pixiv_ugoira_frame_data do |t| + t.change :data, :text, :null => false + t.change :content_type, :string, :null => false + t.remove_timestamps + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 405cb4e1e..d6e07ac4c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2367,10 +2367,8 @@ ALTER SEQUENCE notes_id_seq OWNED BY notes.id; CREATE TABLE pixiv_ugoira_frame_data ( id integer NOT NULL, post_id integer, - data text, - content_type character varying(255), - created_at timestamp without time zone, - updated_at timestamp without time zone + data text NOT NULL, + content_type character varying(255) NOT NULL ); @@ -7119,3 +7117,5 @@ INSERT INTO schema_migrations (version) VALUES ('20140725003232'); INSERT INTO schema_migrations (version) VALUES ('20141009231234'); +INSERT INTO schema_migrations (version) VALUES ('20141017231608'); +