diff options
author | Josh Susser <josh@hasmanythrough.com> | 2010-03-16 23:02:03 -0700 |
---|---|---|
committer | Josh Susser <josh@hasmanythrough.com> | 2010-12-01 10:46:29 -0800 |
commit | 4e4e9ad48a222ac94a904c62ae684c609bd8e177 (patch) | |
tree | 6b2fac055d22c90d22ef2063c0625b7c6082d255 /activerecord/test | |
parent | c283cdd63cafdb04784cfcc5094da41c9268c20c (diff) | |
download | rails-4e4e9ad48a222ac94a904c62ae684c609bd8e177.tar.gz rails-4e4e9ad48a222ac94a904c62ae684c609bd8e177.tar.bz2 rails-4e4e9ad48a222ac94a904c62ae684c609bd8e177.zip |
record migration timestamp when migrations run
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 55a24a94f3..e76097d42d 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -445,6 +445,43 @@ if ActiveRecord::Base.connection.supports_migrations? Person.connection.drop_table table_name rescue nil end + def test_create_table_with_custom_sequence_name + return unless current_adapter? :OracleAdapter + + # table name is 29 chars, the standard sequence name will + # be 33 chars and fail + assert_raise(ActiveRecord::StatementInvalid) do + begin + Person.connection.create_table :table_with_name_thats_just_ok do |t| + t.column :foo, :string, :null => false + end + ensure + Person.connection.drop_table :table_with_name_thats_just_ok rescue nil + end + end + + # should be all good w/ a custom sequence name + assert_nothing_raised do + begin + Person.connection.create_table :table_with_name_thats_just_ok, + :sequence_name => 'suitably_short_seq' do |t| + t.column :foo, :string, :null => false + end + + Person.connection.execute("select suitably_short_seq.nextval from dual") + + ensure + Person.connection.drop_table :table_with_name_thats_just_ok, + :sequence_name => 'suitably_short_seq' rescue nil + end + end + + # confirm the custom sequence got dropped + assert_raise(ActiveRecord::StatementInvalid) do + Person.connection.execute("select suitably_short_seq.nextval from dual") + end + end + # Sybase, and SQLite3 will not allow you to add a NOT NULL # column to a table without a default value. unless current_adapter?(:SybaseAdapter, :SQLite3Adapter) @@ -1462,6 +1499,17 @@ if ActiveRecord::Base.connection.supports_migrations? ActiveRecord::Base.table_name_suffix = "" end + def test_migration_row_includes_timestamp + conn = ActiveRecord::Base.connection + sm_table = ActiveRecord::Migrator.schema_migrations_table_name + + ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") + + conn.select_all("SELECT * FROM #{conn.quote_table_name(sm_table)}").each do |row| + assert_match /^2\d\d\d-/, row["migrated_at"], "missing migrated_at" + end + end + def test_proper_table_name assert_equal "table", ActiveRecord::Migrator.proper_table_name('table') assert_equal "table", ActiveRecord::Migrator.proper_table_name(:table) @@ -2117,4 +2165,3 @@ if ActiveRecord::Base.connection.supports_migrations? end end end - |