Technical
Migrations

To manipulate schema through console


ActiveRecord::Schema.define do
  # Your migrations code create_table add_column e.t.c
end

To set column as and identety using migrations and active record

By default rails will create id column that will work as an identy but some times you will have to use field name different then ID.


 ActiveRecord::Schema.define do
   execute("ALTER TABLE t_discount_set ADD discount_set_id  numeric(31,0) IDENTITY")

 end

To generate test schema without using rake db:test:prepare

I could not execute rake db:test:prepare cause it wipes everything out first, was not very safe for me.

I’ve done following

generate_schema.rb in the root of your app.


ENV['RAILS_ENV'] = 'test'

require File.dirname(__FILE__) + '/config/boot'
require File.join(File.dirname(__FILE__), '/config/boot')
require 'active_record'

ActiveRecord::Schema.define do
 if RAILS_ENV == 'test'
  create_table :some_table_name,:id => false,:force => true do |t|
     t.column "id", :integer, :null => false
     t.column "name", :string, :limit => 30, :null => false
  end

 else
  puts "Please don't run me from development" 
 end
end

I wish I could use migrations(2007)

YAAAAAAAAAAAAAAAAA I CAN USE MIGRATIONS NO MORE WORK AROUNDS