Displaying 20 results from an estimated 74 matches for "add_column".
2006 Sep 05
0
rake craziness with Migrate as a dependency
...sts, 0 assertions, 0 failures, 0 errors
c:\dve\ideeli_trunk\lib\tasks>rake db:migrate --trace
rake db:migrate --trace
(in c:/dve/ideeli_trunk)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
-- create_table("rails_crons")
-> 0.1010s
-- add_column(:rails_crons, :concurrent, :boolean)
-> 0.2100s
** Execute db:migrate
== Init: migrating
============================================================
-- create_table("colors", {:force=>true})
-> 0.0800s
-- add_index("colors", ["product_id", "name&qu...
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
2006 Oct 15
3
Migrations - add_column :default=>true, :null=>false
This seems pretty brain dead:
add_column :types, :notify_on_create, :boolean, {:default=>true,
:null=>false}
$ rake migrate
Error: ERROR: column "notify_on_create" contains null values
: ALTER TABLE types ALTER notify_on_create SET NOT NULL
Why doesn''t Rails set the new column to true, as it''s suppose...
2006 Jul 18
3
DB Migrations & Column Order
...y a table for a has_many
:through and I recently realized that it needs an ID column, unlike
HABTM tables). I am a big perfectionist and I frequently run "SHOW
COLUMNS IN table;", so I naturally expect to see the "id" column the
first one listed. However, if I just do a standard add_column()
migration, the column will appear on the bottom. Is there any way to
re-arrange this? The Rails docs says that there is an options
parameter for add_column, but I couldn''t really find much information
on it. I could, of course, manually write the SQL, but I want to see
if there is a way...
2011 Apr 01
4
add_column not working in migration for sqlite3
Hello,
I developed an app with postgres DB but want to change the DB to
sqlite3. I changed the database adapter in the database.yml file. When I
run the migration most of it was successful but add_column was throwing
an error
"Cannot add a NOT NULL column with default value NULL: ALTER TABLE
"rates" ADD "customer_id" integer NOT NULL".
I made the modification and added the columns to the original migration
of the table and ran the migration again. Everything seems to...
2011 Aug 07
2
PROBLEM WITH PAPERCLIP
...d
4.created a model *picuser *with =>has_attached_file :avatar, :styles =>
{:medium => "300*300>", :thumb => "100*100>" }
created a migration file with following columns => class
AddAvatarColumnsToPicusers < ActiveRecord::Migration
def self.up
add_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_co...
2006 Jul 07
1
Add_column not working
I try to add a column using migration in the table tests with the name
namn as a string. Doesn''t work. Any idea why?
def self.up
add_column :tests, :namn, :string
end
--
Posted via http://www.ruby-forum.com/.
2006 Jun 03
2
migrations unit test and sqlite3 add_column
Hi all,
I submitted a patch the other day for an issue I ran into running an
"add_column" migration on a sqlite3 database when there is existing
data in the table, and the new column has ":null=>false".
Details at http://dev.rubyonrails.org/ticket/5215.
The issue I encountered was not picked due to the unit test not
having any actual data in it before running th...
2009 Sep 03
12
paperclip is not saving the files
...t saving the files
my model has
has_attached_file :attachment,:styles => { :medium => "300x300>",
:thumb => "100x100>" }
and 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_...
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...
2006 Nov 29
2
db:migrate to add colum bombs...
Hi
I get the following when I try and run "rake db:migrate" (I"m running un
Ubuntu linux)
********** code **********
(in /<home hidden>)
== AddRpts: migrating
=========================================================
-- add_column("rpts", :integer, {:limit=>3})
rake aborted!
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
********** code **********
Everything was working fine until my last ''generate'&...
2008 Feb 13
4
Migration Issues: Can't update newly added column values
...been non-destructively deleted. NULL values in
"deleted_at" indicate 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...
2010 Feb 25
2
[PATCH] Enhance vms display
...+# 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.
+
+# introduce information fields for VMs
+class AddVmFields < ActiveRecord::Migration
+ def self.up
+ add_column :vms, :contact, :string, :null => false, :default => ''
+ 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 =>...
2006 Apr 02
5
adding primary_key to join table using migrations
...user_id.
I now want to add a primary key to this model (because I want to add a
"description" column as well so users can describe the tag.
I''m not sure how to add this using migrations.
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, "descript...
2006 Aug 02
2
Help please: AWDWR -- Migration failure
I''m having a problem with one of the migration files from the depot application.
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== AddPrice: migrating ========================================================
-- add_column(:products, :price, :decimal, {:scale=>2, :default=>0, :precision=>
8})
rake aborted!
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]
I''ve checked this against the latest pdf of the b...
2006 May 26
7
migration with required data
...rity.
I generate a Priority model, modify my Bug model with a belongs_to
:priority and create my migration like 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...
2006 Jul 29
3
Engines question
I would like to get at all models in a rails application to be able to
add a field to every one of them as part of a migration. Something
like the following:
Appmodels.each { |x| add_column x.table_name.to_s, :foo, :text }
I understand I can get the table name using
ActiveRecord::Base#table_name, but how do I get all the models into an
array that I can use in the above manner?
--
Cheers,
Hasan Diwan <hasan.diwan@gmail.com>
2006 Aug 04
8
Demo in rails2.pdf of add_price migration, PostgreSQL 8.1.4
...the migrate example on p 74 of the rails2.pdf
It''s a simple example of using a migration to add a column to
the products table.
Here is a copy of the migration file named 002_add_price.rb
after I generated and then edited it:
class AddPrice < ActiveRecord::Migration
def self.up
add_column :products, :price, :decimal, :precision => 8, :scale => 2,
:default => 0
end
def self.down
remove_column :products, :price
end
end
I see this error when I walk through the demo:
bash mac maco /pt/books/rails2_my_depot/depot 9 $
bash mac maco /pt/books/rails2_my_depot/depot 9...
2006 Aug 16
6
Newbie-Question
...D:\ruby\work\depot>rake
db:migrate
(in D:/ruby/work/depot)
== AddPrice: migrating
========================================================
-- add_column(:products, :pice, :decimal, {:default=>0, :precision=>8,
:scale=>2
})
rake aborted!
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]
(See full trace by running task with --trace)
D:\rub...
2008 Jan 16
0
[CruiseControl] RubyOnRails build 8649 failed
...n `test_eager_belongs_to_and_has_one_not_singularized''
./test/../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:90:in `__send__''
./test/../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:90:in `run''
Name: test_add_column_not_null_with_default(MigrationTest)
Type: Failure
Message: Exception raised:
Class: <NameError>
Message: <"undefined local variable or method `quoted_column_name'' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0xb74d5154>">
---Backtrace---
./test/../...