I am creating a new Rails 3.1 application.
I would like this new application to reuses an existing database (which was created by a previous rails 2 application).
I created the new application defining models that reuses some of the existing data in the database.
In the development and test phase everything works fine since it runs on a clean sheet database, but when trying to deploy to production I get messages such as:
PGError: ERROR: column "email" of relation "users" already exists
*** [err :: localhost] : ALTER TABLE "users" ADD COLUMN "email" character varying(255) DEFAULT '' NOT NULL
however I have in my migration thinks like
class DeviseCreateUsers < ActiveRecord::Migration
def change
change_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
t.timestamps
end
end
How can I make db:migrate ignore what already exist and only change the new things and/or new types?
I saw similar questions on stackoverflow, but none answering this question. Thanks for your answers.
If you are using an existing database then you shouldn’t try and override it through migrations, you should replicate the existing database in schema.rb and then migrate forwards from there, only adding the fields that have changed.