diff --git a/app/models/api_key.rb b/app/models/api_key.rb index 04fb0aee877..dc6195baeb1 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 460f8c1ade8..2d2475b66df 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 b06dfb1a2a7..3512806d696 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 253b1aa15ff..2d179a36e89 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 85bfd11b9cb..309ae428268 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 b66a820f744..289846a6b95 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 524f35583bc..feddd95bf09 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 50656dd13fd..db524db0b89 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 d7f70007b69..fa9fd3a21e7 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 c63e8862fa4..38e5a471296 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 2f2b0531aa0..39a7b51eec6 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 a5a9ddaae46..e4ab1480df7 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 067069e5e51..08a9e9615a4 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 ff84943784a..d98ed4326ff 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 e2f10a26847..8ef00720e4e 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 1b4349313a8..c79a3b0e913 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 6c4011142cf..26f3dda50dc 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 9d00deb9025..2f636d6f09a 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 54a8a63b319..302f0493d17 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 1a0a0cc5a00..53ace2df1fd 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 775ff014b53..9064b0d0d0b 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 7cbcf7be0c2..f55f3468757 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 e6bc6845b74..79fcff8b416 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 1ae54913bc9..55ebdcae66b 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 a3034b00a08..7ce0cace41d 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 5144c4f2dea..108b130fbca 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 e46928ff105..4f2f8699c20 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 8f2bddc75c8..39df0288edc 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 2fd28b1f1e8..8f888516732 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 d7de2240d9f..81c39269d15 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 3d20b924d2b..45f9e686958 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 e23456aebcb..5a4ad076733 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 05f0f94222c..5a3a0e08040 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 876e7a2f5fd..b168c0a46fc 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 3b543c7d77c..5abe8aced91 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 e844a78a737..bbccfcb6c96 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 d35bb22f330..58b241d9142 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 1dbc796ebb6..c6f801865da 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 ddb0b60fa7f..8e9533fd4e8 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 24f15544897..4bb981d226c 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 f1663a29379..e495dd24c4a 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 1d284d80a44..662e284cf8b 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 2536d12530b..d6896c6502c 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 8a0c99c95ac..387da91845e 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 e85cccd9eba..a682808b4c4 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 cbb5c4c21c6..42d4f4d83cf 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 ed906a789fa..8b6455769ac 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 c24671b053c..d9f09d17111 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 4280224bf09..8dad28c1ec6 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 9e0c9905c9c..aacdf1c14ab 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 887abd6bd19..3b383d6b3ca 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 0ea46b32437..6f3c393cc54 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 b460bc6f99e..183f2414823 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 00000000000..3f8f2211be5 --- /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