I was able to create a table but i don't know the syntax for adding/ removing fields.
I tried this but it didn't work:
def self.up string :users, :name, :password end
I was able to create a table but i don't know the syntax for adding/ removing fields.
I tried this but it didn't work:
def self.up string :users, :name, :password end
try this
def self.up add_column :modelname, :fieldname, :datatype end
def self.down add_remove_ :modelname, :fieldname end
this one worked: add_column :customers, :firstname, :string
but not this one (multiple fields in one line) add_column :customers, :lastname, :password, :string
also add_remove was not working too.
any ideas?
oren wrote:
this one worked: add_column :customers, :firstname, :string
but not this one (multiple fields in one line) add_column :customers, :lastname, :password, :string
also add_remove was not working too.
any ideas?
Have you read /Agile Web Development with Rails/, by the Daves?
There's really no point in doing anything else first.
If you simply cannot read it, can you Google for add_column? There must be thousands of examples out there, and all about Rails, because nobody else migrates.
i have the book, but havn't read all of it. i thought that it donesn't have info about sexy migrations. i guess i was wrong. thanks!
also add_remove was not working too.
Sorry a typo ...
remove_column :modelname, :fieldname
sexy migrations only enhances creating tables.
once the table is created, and you are adding, removing, anf changing columns, you need to use regular migrations, which is extremely well documented in the active record migrations rdoc.
-Andrew