diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-11-15 13:36:25 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-12-02 02:26:41 +0300 |
commit | dd8680a7ae4be279ae1d90f0889317a1e6ee0d95 (patch) | |
tree | a97ee3dbfe656c3799cfe295e3f585b45d182a72 /db | |
parent | d530085685105e2d7cd6d87ba866756683f0488d (diff) |
Drop temporary tracking table when finished
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20171103140253_track_untracked_uploads.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/db/post_migrate/20171103140253_track_untracked_uploads.rb b/db/post_migrate/20171103140253_track_untracked_uploads.rb index 09ff21b103f..7a34abc85ee 100644 --- a/db/post_migrate/20171103140253_track_untracked_uploads.rb +++ b/db/post_migrate/20171103140253_track_untracked_uploads.rb @@ -10,6 +10,18 @@ class TrackUntrackedUploads < ActiveRecord::Migration MIGRATION = 'PrepareUntrackedUploads' def up + ensure_temporary_tracking_table_exists + + BackgroundMigrationWorker.perform_async(MIGRATION) + end + + def down + if table_exists?(:untracked_files_for_uploads) + drop_table :untracked_files_for_uploads + end + end + + def ensure_temporary_tracking_table_exists unless table_exists?(:untracked_files_for_uploads) create_table :untracked_files_for_uploads do |t| t.string :path, limit: 600, null: false @@ -25,13 +37,5 @@ class TrackUntrackedUploads < ActiveRecord::Migration unless index_exists?(:untracked_files_for_uploads, :tracked) add_index :untracked_files_for_uploads, :tracked end - - BackgroundMigrationWorker.perform_async(MIGRATION) - end - - def down - if table_exists?(:untracked_files_for_uploads) - drop_table :untracked_files_for_uploads - end end end |