Displaying 20 results from an estimated 50 matches for "remove_column".
2011 Aug 07
2
PROBLEM WITH PAPERCLIP
...dd_column :picusers, :avatar_file_name, :string
add_column :picusers, :avatar_content_type, :string
add_column :picusers, :avatar_file_size, :integer
add_column :picusers, :avatar_updated_at, :datetime
end
def
self.down
remove_column :picusers, :avatar_file_name
remove_column :picusers, :avatar_content_type
remove_column :picusers, :avatar_file_size
remove_column :picusers, :avatar_updated_at
end
end...
2006 Jan 14
11
accessing models from migrations
Ok, so now Users need to be associated with Organizations. I''ve
created a migration and added a ''organization_id'' column to the users
table. I want the default organization_id to be the first
Organization. So I have :default => Organization.find(:first). But
it''s complaining about not being able to find the constant
''Organization''.
Any
2010 Feb 25
2
[PATCH] Enhance vms display
...;'
+ add_column :vms, :comment, :string, :null => false, :default => ''
+ add_column :vms, :eol, :date, :null => false, :default => Date.new(1970,01,01).to_s
+ add_column :vms, :os, :string, :null => false, :default => ''
+ end
+
+ def self.down
+ remove_column :vms, :contact
+ remove_column :vms, :comment
+ remove_column :vms, :eol
+ remove_column :vms, :os
+ end
+end
--
1.7.0
2006 Apr 02
5
adding primary_key to join table using migrations
...tions.
Here is what I have:
class AddNotesToTags < ActiveRecord::Migration
def self.up
add_column :tags_questions_users, "id", :primary_key
add_column :tags_questions_users, "description", :string, :limit =>
80, :null => false
end
def self.down
remove_column :tags_questions_users, "id"
remove_column :tags_questions_users, "description"
end
end
That''s giving me this error:
Mysql::Error: #42000You have an error in your SQL syntax; check the manual
that
corresponds to your MySQL server version for the right syntax to...
2008 Feb 13
4
Migration Issues: Can't update newly added column values
...cate a normal, non-deleted record.
The trick and problem is to keep existing records'' is/isn''t deleted
state valid while doing the migration. In order to accomplish this, I
tried to add code after the "add_column" that creates "deleted_at" and
before the "remove_column" that removes the "is_deleted" column to do
this. The code I wrote checks all records and sets "deleted_at" to
"Time.now" if the "is_deleted" field is true. Or, at least that''s the
idea.
Unfortunately, the code to update the field has no effect...
2009 Sep 03
12
paperclip is not saving the files
...i have db migration as
class AddAttachmentToPolicies < ActiveRecord::Migration
def self.up
add_column :policies, :attachment_file_name, :string
add_column :policies, :attachment_content_type, :string
add_column :policies, :attachment_file_size, :integer
end
def self.down
remove_column :policies, :attachment_file_name
remove_column :policies, :attachment_content_type
remove_column :policies, :attachment_file_size
end
end
and I have that plugin as well
but its not saving the files and I''m getting values as null in my DB
for the above set feilds
Plz help me...
2006 Nov 29
2
db:migrate to add colum bombs...
...until my last ''generate'' to create a
migration like so "ruby script/generate migration add_rpts"
My Migration looks like this:
********** code **********
class AddRpts < ActiveRecord::Migration
def self.up
add_column :rpts, :integer
end
def self.down
remove_column :rpts
end
end
********** code **********
Lastly I did some research on this problem and one suggestion was that I
wasn''t running "Edge Rails". So I did the upgrade but I get the EXACT
same error.
I upgraded using the command "sudo rake rails:freeze:edge"
Any help w...
2006 Jul 06
5
Building a standalone application with RoR
Hello,
I have to code a small application for a car repair shop running under
Windows (98 SE but may be my client could upgrade to 2000) and using RoR
is my definite choise !
The app will be powered by WebRick (which is enough powerfull for a
small app used by only ONE user at a time)
My questions are targeted to the best database to use... I had a look to
SQLite and Firebird but support
2006 Apr 03
2
HABTM migrations
...ion script):
@user.teams << Team.find( 3 )
And the SQL pumped at my server is:
INSERT INTO teams_users (`team_id`, `id`, `user_id`) VALUES (3, 3, 34)
Which promptly fails, because the id column already has a row with the
id of 3. I see one immediate solution:
1) after create_table, remove_column :teams_users, ''id''. If that''s even
legal. Would be nice if create_table had it as an option to not make an
ID column, but this''ll do.
But that seems sort of hackneyed. Is is a bug that the ID column is
being manually populated by rails? Doesn''t s...
2006 Jun 15
6
Newbie''s problem with a nil object he didn''t expect!
Dear Rubyists/Rails gurus,
Though I''ve successfully completed the various Rails tutorials online
and the Depot application from the Agile Web Development with Rails
book, I''m still pretty much a Ruby/Rails newbie. I''m trying to learn by
writing my own simple blogging application, but I''ve run into a problem
that has had me scratching my head for a few days now.
2006 May 16
5
rake aborted when adding a column
...39;m having a silly little problem with migrations. All I''m
trying to do is to add an SSN column to my Employees table. I
generated a migration which looks like:
class AddSsn <
ActiveRecord::Migration
def self.up
add_column :employees,
:ssn,
:string
end
def self.down
remove_column :employees,
:ssn
end
end
When I run this, however, I get:
>rake db:migrate
(in C:/workspace/hr)
rake aborted!
uninitialized constant Ssn
I tried running with --trace but I don''t see how that helped. I
did have the migration syntax wrong a couple of times, but now even
tho...
2006 Sep 05
0
rake craziness with Migrate as a dependency
...users_password_index"})
-> 0.1900s
== Init: migrated (5.3370s)
===================================================
== UpdateDateTimeToDate: migrating
============================================
-- add_column(:products, :shipment_received_on, :date, {:null=>true})
-> 0.2000s
-- remove_column(:products, :shipment_received_at)
-> 0.1900s
== UpdateDateTimeToDate: migrated (0.3900s)
===================================
== FixSkusIndex: migrating
====================================================
-- remove_index(:skus, {:name=>"product_color"})
-> 0.2200s
-- add_i...
2006 Apr 05
16
Migration won''t rollback to specific version?
Hi all,
I''m confused about how migrations work. I''ve been using them for a
couple of weeks but haven''t had any serious rollback issues yet. Just
now I added a field to a table with a migration and ran "rake migrate",
which added the field as expected.
This was in the file db/migrate/007_mymigration.rb, making it version 7.
Later I changed my mind and
2010 Aug 25
2
[PATCH] Virtio support
...ll
+++ b/src/db/migrate/044_add_virtio_to_vm_and_nic.rb
@@ -0,0 +1,11 @@
+class AddVirtioToVmAndNic < ActiveRecord::Migration
+ def self.up
+ add_column :vms, :virtio, :boolean, :default => false
+ add_column :nics, :virtio, :boolean, :default => false
+ end
+
+ def self.down
+ remove_column :vms, :virtio
+ remove_column :nics, :virtio
+ end
+end
diff --git a/src/public/stylesheets/components.css b/src/public/stylesheets/components.css
index 2cda65d..70cda97 100644
--- a/src/public/stylesheets/components.css
+++ b/src/public/stylesheets/components.css
@@ -367,6 +367,11 @@
max-wi...
2007 Nov 29
1
Migration Bug?
Please tell me I''m just confused, but this is very strange.
I have a migration like so:
class AddLevelToRequest < ActiveRecord::Migration
def self.up
add_column :requests, :title_levels, :string
end
def self.down
remove_column :requests, :title_levels
end
end
Run the migration, and from the console do:
>> r = Request.new
=> #<Request:0x31a243c @attributes={"title_levels"=>nil,
"department"=>nil, ...
So far so good. My new attribute is there. Now do:
>> r = Request.new(:t...
2010 Sep 21
1
[PATCH] Introduce ability to select any kind of nic model, not just default or virtio.
...+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+class AddModelToNic < ActiveRecord::Migration
+ def self.up
+ add_column :nics, :model, :string
+ remove_column :nics, :virtio
+ end
+
+ def self.down
+ remove_column :nics, :model
+ add_column :nics, :virtio, :boolean, :default => false
+ end
+end
+
diff --git a/src/public/stylesheets/components.css b/src/public/stylesheets/components.css
index 3cdbf49..fe4043e 100644
--- a/src/public/stylesheet...
2006 Jun 09
2
Creating An Extra Association Between Two Tables
Good Friday Everyone :-).
These are my models:
Problem -> has_and_belongs_to_many :tags
Tag -> has_and_belongs_to_many :problems
Now if a tag does not exist and I create it and associate it to the
problem it works
self.tags << Tag.create(:name => tag)
But if I have the tag already in the DB and just want to link it to
another problem it does not really like me. I do it
2006 May 26
7
migration with required data
...ike so:
class CreatePriorities < ActiveRecord::Migration
def self.up
create_table :priorities do |t|
t.column :name, :string, :limit => 25, :null => false
end
add_column :bugs, :priority_id, :integer, { :null => false, :default
=> 1 }
end
def self.down
remove_column :bugs, :priority_id
drop_table :priorities
end
end
My question is how to handle getting data into the Priorities table
during the migration. When I call add_column, I update all Bug records
to have a default Priority_ID of 1, which works as long as I then insert
the Priority values manua...
2006 Aug 09
1
Migrating a Field to External Model
...ger
Product::reset_column_information
Product::find(:all).each do |p|
brand = Brand::create(''name'' => p.attributes[''brand'']) unless
brand = Brand::find_by_name(p.attributes[''brand''])
p.brand = brand
p.save!
end
remove_column :products, :brand
The problem is that p.save! is crashing with a cryptic error,
somewhere within validations. I have tried creating a brand,
associating it, and saving it like this in the console and it seems
to work fine. However ''rake migrate'' consistently fails (both w...
2009 Feb 17
8
Converting Acts_As_Tree to Acts_As_Nested_Set
Hello,
I have a tree structure that needs to be converted into a nested set.
A great deal of work has already been done on the tree items, so
maintaining the integrity of the id''s is mandatory. However I need
the ability to access entire branches of the tree, which is what
Nested set does. Does anyone have any suggestions on how to
efficiently transfer the tree to the nested set and