From eb36ebc384831643530c4c26e4b80bcd5ccffb61 Mon Sep 17 00:00:00 2001
From: Tyler Lemburg <lemburg@unl.edu>
Date: Tue, 14 Mar 2017 10:32:50 -0500
Subject: [PATCH] Add pricture to user table

---
 Gemfile.lock                                  |   5 +-
 .../20170109140000_add_resource_fields.rb     | 101 ++++++++----------
 db/migrate/20170314103000_add_user_picture.rb |   8 ++
 3 files changed, 57 insertions(+), 57 deletions(-)
 create mode 100644 db/migrate/20170314103000_add_user_picture.rb

diff --git a/Gemfile.lock b/Gemfile.lock
index 366c239..97a6b69 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -149,5 +149,8 @@ DEPENDENCIES
   thin
   unicorn
 
+RUBY VERSION
+   ruby 2.2.3p173
+
 BUNDLED WITH
-   1.13.0
+   1.14.6
diff --git a/db/migrate/20170109140000_add_resource_fields.rb b/db/migrate/20170109140000_add_resource_fields.rb
index b69f1aa..942eb05 100644
--- a/db/migrate/20170109140000_add_resource_fields.rb
+++ b/db/migrate/20170109140000_add_resource_fields.rb
@@ -5,60 +5,49 @@ require 'models/resource_field'
 require 'models/resource_field_data'
 
 class AddResourceFields < ActiveRecord::Migration
-	def up
-		# add a table to hold the various "classes" of resources
-		create_table :resource_classes do |t|
-			t.string :name
-		end
-
-		# add a table to hold the various types of fields that get attached to resources
-		create_table :resource_fields do |t|
-			t.string :field_name
-			t.integer :resource_class_id
-		end
-
-		# add a table to contain the actual data
-		create_table :resource_field_data do |t|
-			t.integer :resource_id
-			t.integer :resource_field_id
-			t.string :data
-		end
-
-		# add a column to the resource table to reference its class if it exists
-		add_column :resources, :resource_class_id, :integer
-
-		# we seem to have a random column with no use
-		remove_column :resources, :resource_type
-
-		# add a column to reservations for just extraneous details
-		add_column :reservations, :details, :text
-
-		# move all model data, for NIS resources, into this new arch.
-		# create a class
-		ResourceClass.reset_column_information
-		ResourceField.reset_column_information
-		ResourceFieldData.reset_column_information
-		tool_class = ResourceClass.create(
-			:name => 'Innovation Studio Tool'
-		)
-
-		# add model as a field to this class
-		model_field = tool_class.resource_fields.create(
-			:field_name => 'Model'
-		)
-
-		# for each of those resources, add a field_data with its model
-		Resource.where(:service_space_id => 1).all.each do |resource|
-			ResourceFieldData.create(
-				resource_id: resource.id,
-				resource_field_id: model_field.id,
-				data: resource.model
-			)
-			resource.resource_class_id = tool_class.id
-			resource.save
-		end
-
-		# lastly, drop the column
-		remove_column :resources, :model
-	end
+  def up
+    # add a table to hold the various "classes" of resources
+    create_table :resource_classes do |t|
+      t.string :name
+    end
+
+    # add a table to hold the various types of fields that get attached to resources
+    create_table :resource_fields do |t|
+      t.string :field_name
+      t.integer :resource_class_id
+    end
+
+    # add a table to contain the actual data
+    create_table :resource_field_data do |t|
+      t.integer :resource_id
+      t.integer :resource_field_id
+      t.string :data
+    end
+
+    # add a column to the resource table to reference its class if it exists
+    add_column :resources, :resource_class_id, :integer
+
+    # we seem to have a random column with no use
+    remove_column :resources, :resource_type
+
+    # add a column to reservations for just extraneous details
+    add_column :reservations, :details, :text
+
+    # move all model data, for NIS resources, into this new arch.
+    # create a class
+    ResourceClass.reset_column_information
+    ResourceField.reset_column_information
+    ResourceFieldData.reset_column_information
+    tool_class = ResourceClass.create(
+      :name => 'Innovation Studio Tool'
+    )
+
+    # add model as a field to this class
+    model_field = tool_class.resource_fields.create(
+      :field_name => 'Model'
+    )
+
+    # lastly, drop the column
+    remove_column :resources, :model
+  end
 end
\ No newline at end of file
diff --git a/db/migrate/20170314103000_add_user_picture.rb b/db/migrate/20170314103000_add_user_picture.rb
new file mode 100644
index 0000000..56beabd
--- /dev/null
+++ b/db/migrate/20170314103000_add_user_picture.rb
@@ -0,0 +1,8 @@
+require 'active_record'
+
+class AddUserPicture < ActiveRecord::Migration
+	def change
+    add_column :users, :imagedata, :longblob, :default => nil
+    add_column :users, :imagemime, :string, :default => nil
+	end
+end
\ No newline at end of file
-- 
GitLab