summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-09-21 21:01:58 -0600
committermo khan <mo@mokhan.ca>2014-09-21 21:01:58 -0600
commit4a0e0a9d2764272be3ffd471ce8aac02005c8cc6 (patch)
tree019d0b1a7855e0b53886b594fc544b79a5ebcebd /script
parentc4d58e1862c74d4af0824f6cad56f76b5298ef7f (diff)
change migration to a script.
Diffstat (limited to 'script')
-rw-r--r--script/deploy-production.sh2
-rw-r--r--script/deploy-staging.sh2
-rw-r--r--script/migrate-avatars.rb16
3 files changed, 17 insertions, 3 deletions
diff --git a/script/deploy-production.sh b/script/deploy-production.sh
index 20f78404..deb8ce11 100644
--- a/script/deploy-production.sh
+++ b/script/deploy-production.sh
@@ -1,2 +1,2 @@
#!/bin/bash -x
-bundle exec cap production deploy:migrations
+bundle exec cap production deploy
diff --git a/script/deploy-staging.sh b/script/deploy-staging.sh
deleted file mode 100644
index 66b6d555..00000000
--- a/script/deploy-staging.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash -x
-bundle exec cap staging deploy:migrations
diff --git a/script/migrate-avatars.rb b/script/migrate-avatars.rb
new file mode 100644
index 00000000..6e717cfa
--- /dev/null
+++ b/script/migrate-avatars.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+
+BlobStorage.new.tap do |blob_storage|
+ Avatar.includes(:user).where('avatar IS NOT NULL').find_each do |avatar|
+ begin
+ key = avatar.avatar.path
+ blob_storage.download(key) do |file|
+ puts file.path
+ UploadAvatar.new.run(avatar.user, { photo: { image: file.path } })
+ end
+ rescue StandardError => error
+ puts error.message
+ end
+ end
+end