Displaying 7 results from an estimated 7 matches for "rename_column".
2010 Dec 14
4
Change primary_key column name
Hi,
after changing a primary key column name, the auto-increment information
(MySQL) and sequence (Oracle) are lost. What is the correct way to rename
primary keys?
Thanks,
Gustavo
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2006 Oct 31
4
Auto-increment lost during migration.
Hi. I get some strange results when using rename_column on a primary
key in a migration. It seems like the migration script removes the
auto-increment property if you rename a column.
This is a minimal example.
create_table :foo, :primary_key => :foo_id do |t|
t.column "name", :string
end
# renaming the primary key make...
2006 Jun 05
0
migration to be called inside others migrations
...ow since the rails related columns will be the same for many (but not
all) tables I was thinking... can I write a Migration that sounds like
that
class AddRailsFields < ActiveRecord::Migration
def self.up(tbname)
add_column tbname, "lock_version", :integer, :default => 0
rename_column tbname, "oldtimestamp", "updated_at"
end
def self.down(tbname)
remove_column tbname, "lock_version"
rename_column tbname, "updated_at", "oldtimestamp"
end
end
And call it inside other migrations as
AddRailsFields.up("tablename...
2009 Jan 08
5
There is already an object named 'schema_migrations' in the database
I''ve created a table in a SQL Server database using a migration,
successfully.
I''ve tried to change the name of a column in the table and got the
error message above when running ''rake db:migrate''.
Previously I have developed using MySQL and Sqlite and migrations have
worked successfully. This is an error I have not seen before.
Has anybody seen this and worked
2006 Aug 05
10
Converting mysql to postgres
Hi,
Anyone got any cool tricks for converting a Rails site (in this case,
a typo installation) from a mysql database to a postgresql database?
I''ve got it almost working -- I''m doing a SQL dump from mysql and
loading it into postgres. However, mysql does booleans as a tinyint
with 0 = false and 1 = true. When I try to import that into a
postgres database that expects booleans
2006 Sep 05
0
rake craziness with Migrate as a dependency
...==================================
-- add_column(:offers, "is_drawn", :string, {:default=>"0"})
-> 0.2300s
== AddDrawnFlagToSweepstake: migrated (0.2300s)
===============================
== ChangeEntrantOfferIdFieldToSweepstakeId: migrating
=========================
-- rename_column(:entrants, "offer_id", "sweepstake_id")
-> 0.4810s
== ChangeEntrantOfferIdFieldToSweepstakeId: migrated (0.4810s)
================
== AddPictureToUser: migrating
================================================
-- add_column(:users, "image", :string, {:default=&...
2010 Oct 11
8
Nooby Stuck - "has_and_belongs_to_many" relationship
trying to set up a "has_and_belongs_to_many" relationship
would very much appreciate the help, not sure what im doing wrong at all.
Scheme.rb
class Scheme < ActiveRecord::Base
validates :schemename, :presence => true
belongs_to :user
has_many :levels, :dependent => :destroy
has_and_belongs_to_many :works
end
Work.rb
class Work < ActiveRecord::Base