diff options
| author | mo khan <mo@mokhan.ca> | 2014-09-19 21:41:09 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-09-19 21:41:09 -0600 |
| commit | f8dd07ca99f222cf501f509928c1b77f817d7613 (patch) | |
| tree | a5db69d68e3e7d1493a3a573a0ba9be35af95a1a /db | |
| parent | 05dd5e7595b62475adcbe98b7c8bfc854b34bf7d (diff) | |
make photos polymorphic.
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20140920032230_make_photos_polymorphic.rb | 6 | ||||
| -rw-r--r-- | db/migrate/20140920033516_migrate_old_photos.rb | 7 | ||||
| -rw-r--r-- | db/schema.rb | 7 |
3 files changed, 17 insertions, 3 deletions
diff --git a/db/migrate/20140920032230_make_photos_polymorphic.rb b/db/migrate/20140920032230_make_photos_polymorphic.rb new file mode 100644 index 00000000..8c4f4b36 --- /dev/null +++ b/db/migrate/20140920032230_make_photos_polymorphic.rb @@ -0,0 +1,6 @@ +class MakePhotosPolymorphic < ActiveRecord::Migration + def change + rename_column :photos, :creation_id, :imageable_id + add_column :photos, :imageable_type, :string + end +end diff --git a/db/migrate/20140920033516_migrate_old_photos.rb b/db/migrate/20140920033516_migrate_old_photos.rb new file mode 100644 index 00000000..83a8a9e6 --- /dev/null +++ b/db/migrate/20140920033516_migrate_old_photos.rb @@ -0,0 +1,7 @@ +class MigrateOldPhotos < ActiveRecord::Migration + def change + Photo.find_each do |photo| + photo.update_attribute(:imageable_type, 'Creation') + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1db9130b..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: 20140909030826) do +ActiveRecord::Schema.define(version: 20140920033516) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -108,7 +108,7 @@ ActiveRecord::Schema.define(version: 20140909030826) do end create_table "photos", force: true do |t| - t.integer "creation_id" + t.integer "imageable_id" t.string "image" t.datetime "created_at" t.datetime "updated_at" @@ -120,9 +120,10 @@ ActiveRecord::Schema.define(version: 20140909030826) do t.float "longitude" t.string "sha256" t.string "watermark" + t.string "imageable_type" end - add_index "photos", ["creation_id"], name: "index_photos_on_creation_id", using: :btree + add_index "photos", ["imageable_id"], name: "index_photos_on_imageable_id", using: :btree create_table "taggings", force: true do |t| t.integer "tag_id" |
