Skip to content

A platform for community discussion. Free, open, simple.

DEV: Promote old post-deploy migrations to pre-deploy migrations (#13477)

David Taylore76c583b91f7
diff --git a/db/post_migrate/20180917024729_remove_superfluous_columns.rb b/db/migrate/20180917024729_remove_superfluous_columns.rb
similarity index 100%
rename from db/post_migrate/20180917024729_remove_superfluous_columns.rb
rename to db/migrate/20180917024729_remove_superfluous_columns.rb
diff --git a/db/post_migrate/20180917034056_remove_superfluous_tables.rb b/db/migrate/20180917034056_remove_superfluous_tables.rb
similarity index 100%
rename from db/post_migrate/20180917034056_remove_superfluous_tables.rb
rename to db/migrate/20180917034056_remove_superfluous_tables.rb
diff --git a/db/post_migrate/20181012123001_drop_group_locked_trust_level_from_user.rb b/db/migrate/20181012123001_drop_group_locked_trust_level_from_user.rb
similarity index 100%
rename from db/post_migrate/20181012123001_drop_group_locked_trust_level_from_user.rb
rename to db/migrate/20181012123001_drop_group_locked_trust_level_from_user.rb
diff --git a/db/post_migrate/20181112013117_migrate_url_site_settings.rb b/db/migrate/20181112013117_migrate_url_site_settings.rb
similarity index 100%
rename from db/post_migrate/20181112013117_migrate_url_site_settings.rb
rename to db/migrate/20181112013117_migrate_url_site_settings.rb
diff --git a/db/post_migrate/20190103065652_remove_uploaded_meta_id_from_category.rb b/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
similarity index 100%
rename from db/post_migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
rename to db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
diff --git a/db/post_migrate/20190121203023_drop_queued_post_id_from_user_actions.rb b/db/migrate/20190121203023_drop_queued_post_id_from_user_actions.rb
similarity index 100%
rename from db/post_migrate/20190121203023_drop_queued_post_id_from_user_actions.rb
rename to db/migrate/20190121203023_drop_queued_post_id_from_user_actions.rb
diff --git a/db/post_migrate/20190123171817_drop_queued_posts.rb b/db/migrate/20190123171817_drop_queued_posts.rb
similarity index 100%
rename from db/post_migrate/20190123171817_drop_queued_posts.rb
rename to db/migrate/20190123171817_drop_queued_posts.rb
diff --git a/db/post_migrate/20190205104116_drop_unused_auth_tables.rb b/db/migrate/20190205104116_drop_unused_auth_tables.rb
similarity index 100%
rename from db/post_migrate/20190205104116_drop_unused_auth_tables.rb
rename to db/migrate/20190205104116_drop_unused_auth_tables.rb
diff --git a/db/post_migrate/20190208144706_drop_unused_auth_tables_again.rb b/db/migrate/20190208144706_drop_unused_auth_tables_again.rb
similarity index 100%
rename from db/post_migrate/20190208144706_drop_unused_auth_tables_again.rb
rename to db/migrate/20190208144706_drop_unused_auth_tables_again.rb
diff --git a/db/post_migrate/20190312194528_drop_email_user_options_columns.rb b/db/migrate/20190312194528_drop_email_user_options_columns.rb
similarity index 100%
rename from db/post_migrate/20190312194528_drop_email_user_options_columns.rb
rename to db/migrate/20190312194528_drop_email_user_options_columns.rb
diff --git a/db/post_migrate/20190508141824_drop_claimed_by_id.rb b/db/migrate/20190508141824_drop_claimed_by_id.rb
similarity index 100%
rename from db/post_migrate/20190508141824_drop_claimed_by_id.rb
rename to db/migrate/20190508141824_drop_claimed_by_id.rb
diff --git a/db/post_migrate/20190716124050_remove_via_email_from_invite.rb b/db/migrate/20190716124050_remove_via_email_from_invite.rb
similarity index 100%
rename from db/post_migrate/20190716124050_remove_via_email_from_invite.rb
rename to db/migrate/20190716124050_remove_via_email_from_invite.rb
diff --git a/db/post_migrate/20191107032231_change_notification_level.rb b/db/migrate/20191107032231_change_notification_level.rb
similarity index 100%
rename from db/post_migrate/20191107032231_change_notification_level.rb
rename to db/migrate/20191107032231_change_notification_level.rb
diff --git a/db/post_migrate/20191107190330_remove_suppress_from_latest_from_category.rb b/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
similarity index 100%
rename from db/post_migrate/20191107190330_remove_suppress_from_latest_from_category.rb
rename to db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
diff --git a/db/post_migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb b/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
similarity index 100%
rename from db/post_migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
rename to db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
diff --git a/db/post_migrate/20191219112000_remove_key_from_api_keys.rb b/db/migrate/20191219112000_remove_key_from_api_keys.rb
similarity index 100%
rename from db/post_migrate/20191219112000_remove_key_from_api_keys.rb
rename to db/migrate/20191219112000_remove_key_from_api_keys.rb
diff --git a/db/post_migrate/20200117174646_make_post_reply_id_column_read_only.rb b/db/migrate/20200117174646_make_post_reply_id_column_read_only.rb
similarity index 100%
rename from db/post_migrate/20200117174646_make_post_reply_id_column_read_only.rb
rename to db/migrate/20200117174646_make_post_reply_id_column_read_only.rb
diff --git a/db/post_migrate/20200120131338_drop_unused_columns.rb b/db/migrate/20200120131338_drop_unused_columns.rb
similarity index 100%
rename from db/post_migrate/20200120131338_drop_unused_columns.rb
rename to db/migrate/20200120131338_drop_unused_columns.rb
diff --git a/db/post_migrate/20200330233427_drop_old_unread_pm_notification_indices.rb b/db/migrate/20200330233427_drop_old_unread_pm_notification_indices.rb
similarity index 100%
rename from db/post_migrate/20200330233427_drop_old_unread_pm_notification_indices.rb
rename to db/migrate/20200330233427_drop_old_unread_pm_notification_indices.rb
diff --git a/db/post_migrate/20200408121312_remove_key_from_user_api_key.rb b/db/migrate/20200408121312_remove_key_from_user_api_key.rb
similarity index 100%
rename from db/post_migrate/20200408121312_remove_key_from_user_api_key.rb
rename to db/migrate/20200408121312_remove_key_from_user_api_key.rb
diff --git a/db/post_migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb b/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
similarity index 100%
rename from db/post_migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
rename to db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
diff --git a/db/post_migrate/20200424032633_remove_canonical_email_from_user_emails.rb b/db/migrate/20200424032633_remove_canonical_email_from_user_emails.rb
similarity index 100%
rename from db/post_migrate/20200424032633_remove_canonical_email_from_user_emails.rb
rename to db/migrate/20200424032633_remove_canonical_email_from_user_emails.rb
diff --git a/db/post_migrate/20200430010528_remove_avg_time_from_topics_posts.rb b/db/migrate/20200430010528_remove_avg_time_from_topics_posts.rb
similarity index 100%
rename from db/post_migrate/20200430010528_remove_avg_time_from_topics_posts.rb
rename to db/migrate/20200430010528_remove_avg_time_from_topics_posts.rb
diff --git a/db/post_migrate/20200508141209_allow_null_old_email_on_email_change_requests.rb b/db/migrate/20200508141209_allow_null_old_email_on_email_change_requests.rb
similarity index 100%
rename from db/post_migrate/20200508141209_allow_null_old_email_on_email_change_requests.rb
rename to db/migrate/20200508141209_allow_null_old_email_on_email_change_requests.rb
diff --git a/db/post_migrate/20200513185052_drop_topic_reply_count.rb b/db/migrate/20200513185052_drop_topic_reply_count.rb
similarity index 100%
rename from db/post_migrate/20200513185052_drop_topic_reply_count.rb
rename to db/migrate/20200513185052_drop_topic_reply_count.rb
diff --git a/db/post_migrate/20200520001619_remove_fks_from_bookmarks.rb b/db/migrate/20200520001619_remove_fks_from_bookmarks.rb
similarity index 100%
rename from db/post_migrate/20200520001619_remove_fks_from_bookmarks.rb
rename to db/migrate/20200520001619_remove_fks_from_bookmarks.rb
diff --git a/db/post_migrate/20200522004855_remove_access_control_post_fk.rb b/db/migrate/20200522004855_remove_access_control_post_fk.rb
similarity index 100%
rename from db/post_migrate/20200522004855_remove_access_control_post_fk.rb
rename to db/migrate/20200522004855_remove_access_control_post_fk.rb
diff --git a/db/post_migrate/20200601111500_remove_image_url_from_post_and_topic.rb b/db/migrate/20200601111500_remove_image_url_from_post_and_topic.rb
similarity index 100%
rename from db/post_migrate/20200601111500_remove_image_url_from_post_and_topic.rb
rename to db/migrate/20200601111500_remove_image_url_from_post_and_topic.rb
diff --git a/db/post_migrate/20200610150900_correct_posts_schema.rb b/db/migrate/20200610150900_correct_posts_schema.rb
similarity index 100%
rename from db/post_migrate/20200610150900_correct_posts_schema.rb
rename to db/migrate/20200610150900_correct_posts_schema.rb
diff --git a/lib/migration/safe_migrate.rb b/lib/migration/safe_migrate.rb
index 0b65ee0a261..3b4a386dfaf 100644
--- a/lib/migration/safe_migrate.rb
+++ b/lib/migration/safe_migrate.rb
@@ -6,7 +6,6 @@ class Discourse::InvalidMigration < StandardError; end
class Migration::SafeMigrate
module SafeMigration
- UNSAFE_VERSION = 20180321015220
@@enable_safe = true
def self.enable_safe!
@@ -19,7 +18,7 @@ class Migration::SafeMigrate
def migrate(direction)
if direction == :up &&
- version && version > UNSAFE_VERSION &&
+ version && version > Migration::SafeMigrate.earliest_post_deploy_version &&
@@enable_safe != false &&
!is_post_deploy_migration?
@@ -153,4 +152,12 @@ class Migration::SafeMigrate
raise Discourse::InvalidMigration, "Attempt was made to rename or delete column"
end
end
+
+ def self.earliest_post_deploy_version
+ @@earliest_post_deploy_version ||= begin
+ first_file = Dir.glob("#{Discourse::DB_POST_MIGRATE_PATH}/*.rb").sort.first
+ file_name = File.basename(first_file, ".rb")
+ file_name.first(14).to_i
+ end
+ end
end