in Programming, Uncategorized

Change the data type of a column in the database

I accidentally created a column in the database with the datatype of string when it needed to be a integer. I’m on the BART, so I didn’t have internet. Fortunately I have a copy of the Rails repo and its guides. I opened up and read to the changing tables section. Saw the following:

change_table :products do |t|
  t.remove :description, :name
  t.string :part_number
  t.index :part_number
  t.rename :upccode, :upc_code

I followed this and created the following migration:

change_tabe :products do |t|
  t.remove :price_in_cents
  t.integer :price_in_cents

Write a Comment