File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
lib/active_record/connection_adapters/oracle_enhanced
spec/active_record/connection_adapters/oracle_enhanced Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -622,6 +622,13 @@ def create_alter_table(name)
622622 OracleEnhanced ::AlterTable . new create_table_definition ( name )
623623 end
624624
625+ def add_timestamps ( table_name , **options )
626+ fragments = add_timestamps_for_alter ( table_name , **options )
627+ fragments . each do |fragment |
628+ execute "ALTER TABLE #{ quote_table_name ( table_name ) } #{ fragment } "
629+ end
630+ end
631+
625632 def update_table_definition ( table_name , base )
626633 OracleEnhanced ::Table . new ( table_name , base )
627634 end
Original file line number Diff line number Diff line change @@ -387,6 +387,34 @@ class ::TestEmployee < ActiveRecord::Base; end
387387 end
388388end
389389
390+ describe "add timestamps" do
391+ before ( :each ) do
392+ @conn = ActiveRecord ::Base . connection
393+ schema_define do
394+ create_table :test_employees , force : true
395+ end
396+ class ::TestEmployee < ActiveRecord ::Base ; end
397+ end
398+
399+ after ( :each ) do
400+ schema_define do
401+ drop_table :test_employees , if_exists : true
402+ end
403+ Object . send ( :remove_const , "TestEmployee" )
404+ ActiveRecord ::Base . clear_cache!
405+ end
406+
407+ it "should add created_at and updated_at" do
408+ expect do
409+ @conn . add_timestamps ( "test_employees" )
410+ end . not_to raise_error
411+
412+ TestEmployee . reset_column_information
413+ expect ( TestEmployee . columns_hash [ "created_at" ] ) . not_to be_nil
414+ expect ( TestEmployee . columns_hash [ "updated_at" ] ) . not_to be_nil
415+ end
416+ end
417+
390418 describe "ignore options for LOB columns" do
391419 after ( :each ) do
392420 schema_define do
You can’t perform that action at this time.
0 commit comments