summaryrefslogtreecommitdiff
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
parentc4d58e1862c74d4af0824f6cad56f76b5298ef7f (diff)
change migration to a script.
-rw-r--r--db/migrate/20140921024709_migrate_avatars_to_photos.rb19
-rw-r--r--db/schema.rb2
-rw-r--r--script/deploy-production.sh2
-rw-r--r--script/deploy-staging.sh2
-rw-r--r--script/migrate-avatars.rb16
5 files changed, 18 insertions, 23 deletions
diff --git a/db/migrate/20140921024709_migrate_avatars_to_photos.rb b/db/migrate/20140921024709_migrate_avatars_to_photos.rb
deleted file mode 100644
index 18d01235..00000000
--- a/db/migrate/20140921024709_migrate_avatars_to_photos.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class MigrateAvatarsToPhotos < ActiveRecord::Migration
- def change
- BlobStorage.new.tap do |blob_storage|
- Avatar.includes(:user).where('avatar IS NOT NULL').find_each do |avatar|
- begin
- user = avatar.user
- key = avatar.avatar.path
- blob_storage.download(key) do |file|
- user.avatar = Photo.create!
- user.avatar.upload(file.path, blob_storage)
- user.avatar.save!
- end
- rescue StandardError => error
- say error.message
- end
- end
- end
- end
-end
diff --git a/db/schema.rb b/db/schema.rb
index 825289ef..5e98aa87 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140921024709) do
+ActiveRecord::Schema.define(version: 20140920033516) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
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