ActiveRecord::Schema.define do
# Your migrations code create_table add_column e.t.c
end
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
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
So I am stuck with ruby 1.8.4 ( they just don’t want to migrate ) there fore I have to use old rubygems e.t.c. So now when I am trying to generate migration i get undefined method `collect’ for #<Gem::Version::Requirement:0xb768ce48> – which translates to me tough luck. So anyways to make long story short. Rails 2.2.2 using the following strftime to generate timestamp:
Time.now.utc.strftime("%Y%m%d%H%M%S") #=> "20090203160152"