diff --git a/app/models/api_key.rb b/app/models/api_key.rb index 04fb0aee8..dc6195bae 100644 --- a/app/models/api_key.rb +++ b/app/models/api_key.rb @@ -29,8 +29,8 @@ end # key :string(64) not null # user_id :integer # created_by_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/badge.rb b/app/models/badge.rb index 460f8c1ad..2d2475b66 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -247,8 +247,8 @@ end # description :text # badge_type_id :integer not null # grant_count :integer default(0), not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # allow_title :boolean default(FALSE), not null # multiple_grant :boolean default(FALSE), not null # icon :string(255) default("fa-certificate") diff --git a/app/models/badge_grouping.rb b/app/models/badge_grouping.rb index b06dfb1a2..3512806d6 100644 --- a/app/models/badge_grouping.rb +++ b/app/models/badge_grouping.rb @@ -25,6 +25,6 @@ end # name :string(255) not null # description :text # position :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # diff --git a/app/models/badge_type.rb b/app/models/badge_type.rb index 253b1aa15..2d179a36e 100644 --- a/app/models/badge_type.rb +++ b/app/models/badge_type.rb @@ -14,8 +14,8 @@ end # # id :integer not null, primary key # name :string(255) not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/category.rb b/app/models/category.rb index 85bfd11b9..309ae4282 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -361,8 +361,8 @@ end # color :string(6) default("AB9364"), not null # topic_id :integer # topic_count :integer default(0), not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # user_id :integer not null # topics_year :integer default(0) # topics_month :integer default(0) diff --git a/app/models/category_custom_field.rb b/app/models/category_custom_field.rb index b66a820f7..289846a6b 100644 --- a/app/models/category_custom_field.rb +++ b/app/models/category_custom_field.rb @@ -10,8 +10,8 @@ end # category_id :integer not null # name :string(256) not null # value :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/category_featured_topic.rb b/app/models/category_featured_topic.rb index 524f35583..feddd95bf 100644 --- a/app/models/category_featured_topic.rb +++ b/app/models/category_featured_topic.rb @@ -51,8 +51,8 @@ end # # category_id :integer not null # topic_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # rank :integer default(0), not null # id :integer not null, primary key # diff --git a/app/models/category_featured_user.rb b/app/models/category_featured_user.rb index 50656dd13..db524db0b 100644 --- a/app/models/category_featured_user.rb +++ b/app/models/category_featured_user.rb @@ -53,8 +53,8 @@ end # id :integer not null, primary key # category_id :integer # user_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/category_group.rb b/app/models/category_group.rb index d7f70007b..fa9fd3a21 100644 --- a/app/models/category_group.rb +++ b/app/models/category_group.rb @@ -15,7 +15,7 @@ end # id :integer not null, primary key # category_id :integer not null # group_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # permission_type :integer default(1) # diff --git a/app/models/color_scheme.rb b/app/models/color_scheme.rb index c63e8862f..38e5a4712 100644 --- a/app/models/color_scheme.rb +++ b/app/models/color_scheme.rb @@ -104,6 +104,6 @@ end # enabled :boolean default(FALSE), not null # versioned_id :integer # version :integer default(1), not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # diff --git a/app/models/color_scheme_color.rb b/app/models/color_scheme_color.rb index 2f2b0531a..39a7b51ee 100644 --- a/app/models/color_scheme_color.rb +++ b/app/models/color_scheme_color.rb @@ -12,8 +12,8 @@ end # name :string(255) not null # hex :string(255) not null # color_scheme_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/draft.rb b/app/models/draft.rb index a5a9ddaae..e4ab1480d 100644 --- a/app/models/draft.rb +++ b/app/models/draft.rb @@ -44,8 +44,8 @@ end # user_id :integer not null # draft_key :string(255) not null # data :text not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # sequence :integer default(0), not null # # Indexes diff --git a/app/models/email_log.rb b/app/models/email_log.rb index 067069e5e..08a9e9615 100644 --- a/app/models/email_log.rb +++ b/app/models/email_log.rb @@ -37,8 +37,8 @@ end # to_address :string(255) not null # email_type :string(255) not null # user_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # reply_key :string(32) # post_id :integer # topic_id :integer diff --git a/app/models/email_token.rb b/app/models/email_token.rb index ff8494378..d98ed4326 100644 --- a/app/models/email_token.rb +++ b/app/models/email_token.rb @@ -79,8 +79,8 @@ end # token :string(255) not null # confirmed :boolean default(FALSE), not null # expired :boolean default(FALSE), not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/facebook_user_info.rb b/app/models/facebook_user_info.rb index e2f10a268..8ef00720e 100644 --- a/app/models/facebook_user_info.rb +++ b/app/models/facebook_user_info.rb @@ -16,8 +16,8 @@ end # gender :string(255) # name :string(255) # link :string(255) -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/github_user_info.rb b/app/models/github_user_info.rb index 1b4349313..c79a3b0e9 100644 --- a/app/models/github_user_info.rb +++ b/app/models/github_user_info.rb @@ -10,8 +10,8 @@ end # user_id :integer not null # screen_name :string(255) not null # github_user_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/google_user_info.rb b/app/models/google_user_info.rb index 6c4011142..26f3dda50 100644 --- a/app/models/google_user_info.rb +++ b/app/models/google_user_info.rb @@ -17,8 +17,8 @@ end # link :string(255) # profile_link :string(255) # picture :string(255) -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/group.rb b/app/models/group.rb index 9d00deb90..2f636d6f0 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -295,8 +295,8 @@ end # # id :integer not null, primary key # name :string(255) not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # automatic :boolean default(FALSE), not null # user_count :integer default(0), not null # alias_level :integer default(0) diff --git a/app/models/group_custom_field.rb b/app/models/group_custom_field.rb index 54a8a63b3..302f0493d 100644 --- a/app/models/group_custom_field.rb +++ b/app/models/group_custom_field.rb @@ -10,8 +10,8 @@ end # group_id :integer not null # name :string(256) not null # value :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/group_user.rb b/app/models/group_user.rb index 1a0a0cc5a..53ace2df1 100644 --- a/app/models/group_user.rb +++ b/app/models/group_user.rb @@ -10,8 +10,8 @@ end # id :integer not null, primary key # group_id :integer not null # user_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/incoming_link.rb b/app/models/incoming_link.rb index 775ff014b..9064b0d0d 100644 --- a/app/models/incoming_link.rb +++ b/app/models/incoming_link.rb @@ -115,7 +115,7 @@ end # Table name: incoming_links # # id :integer not null, primary key -# created_at :datetime +# created_at :datetime not null # user_id :integer # ip_address :inet # current_user_id :integer diff --git a/app/models/invite.rb b/app/models/invite.rb index 7cbcf7be0..f55f34687 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -198,8 +198,8 @@ end # invited_by_id :integer not null # user_id :integer # redeemed_at :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # deleted_at :datetime # deleted_by_id :integer # invalidated_at :datetime diff --git a/app/models/invited_group.rb b/app/models/invited_group.rb index e6bc6845b..79fcff8b4 100644 --- a/app/models/invited_group.rb +++ b/app/models/invited_group.rb @@ -10,6 +10,6 @@ end # id :integer not null, primary key # group_id :integer # invite_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # diff --git a/app/models/notification.rb b/app/models/notification.rb index 1ae54913b..55ebdcae6 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -143,8 +143,8 @@ end # user_id :integer not null # data :string(1000) not null # read :boolean default(FALSE), not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # topic_id :integer # post_number :integer # post_action_id :integer diff --git a/app/models/oauth2_user_info.rb b/app/models/oauth2_user_info.rb index a3034b00a..7ce0cace4 100644 --- a/app/models/oauth2_user_info.rb +++ b/app/models/oauth2_user_info.rb @@ -13,8 +13,8 @@ end # provider :string(255) not null # email :string(255) # name :string(255) -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/post_action.rb b/app/models/post_action.rb index 5144c4f2d..108b130fb 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -447,8 +447,8 @@ end # user_id :integer not null # post_action_type_id :integer not null # deleted_at :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # deleted_by_id :integer # related_post_id :integer # staff_took_action :boolean default(FALSE), not null diff --git a/app/models/post_action_type.rb b/app/models/post_action_type.rb index e46928ff1..4f2f8699c 100644 --- a/app/models/post_action_type.rb +++ b/app/models/post_action_type.rb @@ -49,8 +49,8 @@ end # name_key :string(50) not null # is_flag :boolean default(FALSE), not null # icon :string(20) -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # id :integer not null, primary key # position :integer default(0), not null # diff --git a/app/models/post_custom_field.rb b/app/models/post_custom_field.rb index 8f2bddc75..39df0288e 100644 --- a/app/models/post_custom_field.rb +++ b/app/models/post_custom_field.rb @@ -10,8 +10,8 @@ end # post_id :integer not null # name :string(256) not null # value :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/post_detail.rb b/app/models/post_detail.rb index 2fd28b1f1..8f8885167 100644 --- a/app/models/post_detail.rb +++ b/app/models/post_detail.rb @@ -14,8 +14,8 @@ end # key :string(255) # value :string(255) # extra :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/post_reply.rb b/app/models/post_reply.rb index d7de2240d..81c39269d 100644 --- a/app/models/post_reply.rb +++ b/app/models/post_reply.rb @@ -11,8 +11,8 @@ end # # post_id :integer # reply_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/post_revision.rb b/app/models/post_revision.rb index 3d20b924d..45f9e6869 100644 --- a/app/models/post_revision.rb +++ b/app/models/post_revision.rb @@ -117,8 +117,8 @@ end # post_id :integer # modifications :text # number :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/quoted_post.rb b/app/models/quoted_post.rb index e23456aeb..5a4ad0767 100644 --- a/app/models/quoted_post.rb +++ b/app/models/quoted_post.rb @@ -66,8 +66,8 @@ end # id :integer not null, primary key # post_id :integer not null # quoted_post_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/screened_email.rb b/app/models/screened_email.rb index 05f0f9422..5a3a0e080 100644 --- a/app/models/screened_email.rb +++ b/app/models/screened_email.rb @@ -71,8 +71,8 @@ end # action_type :integer not null # match_count :integer default(0), not null # last_match_at :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # ip_address :inet # # Indexes diff --git a/app/models/screened_ip_address.rb b/app/models/screened_ip_address.rb index 876e7a2f5..b168c0a46 100644 --- a/app/models/screened_ip_address.rb +++ b/app/models/screened_ip_address.rb @@ -92,8 +92,8 @@ end # action_type :integer not null # match_count :integer default(0), not null # last_match_at :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/screened_url.rb b/app/models/screened_url.rb index 3b543c7d7..5abe8aced 100644 --- a/app/models/screened_url.rb +++ b/app/models/screened_url.rb @@ -47,8 +47,8 @@ end # action_type :integer not null # match_count :integer default(0), not null # last_match_at :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # ip_address :inet # # Indexes diff --git a/app/models/single_sign_on_record.rb b/app/models/single_sign_on_record.rb index e844a78a7..bbccfcb6c 100644 --- a/app/models/single_sign_on_record.rb +++ b/app/models/single_sign_on_record.rb @@ -10,8 +10,8 @@ end # user_id :integer not null # external_id :string(255) not null # last_payload :text not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # external_username :string(255) # external_email :string(255) # external_name :string(255) diff --git a/app/models/site_content.rb b/app/models/site_content.rb index d35bb22f3..58b241d91 100644 --- a/app/models/site_content.rb +++ b/app/models/site_content.rb @@ -36,8 +36,8 @@ end # # content_type :string(255) not null, primary key # content :text not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/site_customization.rb b/app/models/site_customization.rb index 1dbc796eb..c6f801865 100644 --- a/app/models/site_customization.rb +++ b/app/models/site_customization.rb @@ -207,8 +207,8 @@ end # user_id :integer not null # enabled :boolean not null # key :string(255) not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # override_default_style :boolean default(FALSE), not null # stylesheet_baked :text default(""), not null # mobile_stylesheet :text diff --git a/app/models/topic.rb b/app/models/topic.rb index ddb0b60fa..8e9533fd4 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -846,8 +846,8 @@ end # id :integer not null, primary key # title :string(255) not null # last_posted_at :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # views :integer default(0), not null # posts_count :integer default(0), not null # user_id :integer diff --git a/app/models/topic_allowed_user.rb b/app/models/topic_allowed_user.rb index 24f155448..4bb981d22 100644 --- a/app/models/topic_allowed_user.rb +++ b/app/models/topic_allowed_user.rb @@ -12,8 +12,8 @@ end # id :integer not null, primary key # user_id :integer not null # topic_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/topic_custom_field.rb b/app/models/topic_custom_field.rb index f1663a293..e495dd24c 100644 --- a/app/models/topic_custom_field.rb +++ b/app/models/topic_custom_field.rb @@ -10,8 +10,8 @@ end # topic_id :integer not null # name :string(256) not null # value :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rb index 1d284d80a..662e284cf 100644 --- a/app/models/topic_embed.rb +++ b/app/models/topic_embed.rb @@ -168,8 +168,8 @@ end # post_id :integer not null # embed_url :string(255) not null # content_sha1 :string(40) -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/topic_invite.rb b/app/models/topic_invite.rb index 2536d1253..d6896c650 100644 --- a/app/models/topic_invite.rb +++ b/app/models/topic_invite.rb @@ -15,8 +15,8 @@ end # id :integer not null, primary key # topic_id :integer not null # invite_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/topic_link.rb b/app/models/topic_link.rb index 8a0c99c95..387da9184 100644 --- a/app/models/topic_link.rb +++ b/app/models/topic_link.rb @@ -220,8 +220,8 @@ end # domain :string(100) not null # internal :boolean default(FALSE), not null # link_topic_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # reflection :boolean default(FALSE) # clicks :integer default(0), not null # link_post_id :integer diff --git a/app/models/topic_link_click.rb b/app/models/topic_link_click.rb index e85cccd9e..a682808b4 100644 --- a/app/models/topic_link_click.rb +++ b/app/models/topic_link_click.rb @@ -58,8 +58,8 @@ end # id :integer not null, primary key # topic_link_id :integer not null # user_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # ip_address :inet not null # # Indexes diff --git a/app/models/twitter_user_info.rb b/app/models/twitter_user_info.rb index cbb5c4c21..42d4f4d83 100644 --- a/app/models/twitter_user_info.rb +++ b/app/models/twitter_user_info.rb @@ -10,8 +10,8 @@ end # user_id :integer not null # screen_name :string(255) not null # twitter_user_id :integer not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/upload.rb b/app/models/upload.rb index ed906a789..8b6455769 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -135,8 +135,8 @@ end # width :integer # height :integer # url :string(255) not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # sha1 :string(40) # origin :string(1000) # diff --git a/app/models/user.rb b/app/models/user.rb index c24671b05..d9f09d171 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -765,8 +765,8 @@ end # # id :integer not null, primary key # username :string(60) not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # name :string(255) # seen_notification_id :integer default(0), not null # last_posted_at :datetime @@ -805,8 +805,8 @@ end # uploaded_avatar_id :integer # email_always :boolean default(FALSE), not null # mailing_list_mode :boolean default(FALSE), not null -# locale :string(10) # primary_group_id :integer +# locale :string(10) # registration_ip_address :inet # last_redirected_to_top_at :datetime # disable_jump_reply :boolean default(FALSE), not null diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 4280224bf..8dad28c1e 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -331,8 +331,8 @@ end # target_post_id :integer # target_user_id :integer # acting_user_id :integer -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/user_avatar.rb b/app/models/user_avatar.rb index 9e0c9905c..aacdf1c14 100644 --- a/app/models/user_avatar.rb +++ b/app/models/user_avatar.rb @@ -48,8 +48,8 @@ end # custom_upload_id :integer # gravatar_upload_id :integer # last_gravatar_download_attempt :datetime -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/user_custom_field.rb b/app/models/user_custom_field.rb index 887abd6bd..3b383d6b3 100644 --- a/app/models/user_custom_field.rb +++ b/app/models/user_custom_field.rb @@ -10,8 +10,8 @@ end # user_id :integer not null # name :string(256) not null # value :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # # Indexes # diff --git a/app/models/user_history.rb b/app/models/user_history.rb index 0ea46b324..6f3c393cc 100644 --- a/app/models/user_history.rb +++ b/app/models/user_history.rb @@ -105,8 +105,8 @@ end # acting_user_id :integer # target_user_id :integer # details :text -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # context :string(255) # ip_address :string(255) # email :string(255) diff --git a/app/models/user_open_id.rb b/app/models/user_open_id.rb index b460bc6f9..183f24148 100644 --- a/app/models/user_open_id.rb +++ b/app/models/user_open_id.rb @@ -13,8 +13,8 @@ end # user_id :integer not null # email :string(255) not null # url :string(255) not null -# created_at :datetime -# updated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null # active :boolean not null # # Indexes diff --git a/db/migrate/20140827044811_remove_nullable_dates.rb b/db/migrate/20140827044811_remove_nullable_dates.rb new file mode 100644 index 000000000..3f8f2211b --- /dev/null +++ b/db/migrate/20140827044811_remove_nullable_dates.rb @@ -0,0 +1,42 @@ +class RemoveNullableDates < ActiveRecord::Migration + def up + + # must drop so we can muck with the column + execute "DROP VIEW badge_posts" + + # Rails 3 used to have nullable created_at and updated_at dates + # this is no longer the case in Rails 4, some old installs have + # this relic + # Fix it + sql = "select table_name, column_name from information_schema.columns + WHERE column_name IN ('created_at','updated_at') AND + table_schema = 'public' AND + is_nullable = 'YES' AND + is_updatable = 'YES' AND + data_type = 'timestamp without time zone'" + + execute(sql).each do |row| + table = row["table_name"] + column = row["column_name"] + + execute "UPDATE \"#{table}\" SET #{column} = CURRENT_TIMESTAMP WHERE #{column} IS NULL" + change_column table.to_sym, column.to_sym, :datetime, null: false + end + + execute "CREATE VIEW badge_posts AS + SELECT p.* + FROM posts p + JOIN topics t ON t.id = p.topic_id + JOIN categories c ON c.id = t.category_id + WHERE c.allow_badges AND + p.deleted_at IS NULL AND + t.deleted_at IS NULL AND + NOT c.read_restricted AND + t.visible" + + end + + def down + # no need to revert + end +end