Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ def create_alter_table(name)
OracleEnhanced::AlterTable.new create_table_definition(name)
end

def add_timestamps(table_name, **options)
fragments = add_timestamps_for_alter(table_name, **options)
fragments.each do |fragment|
execute "ALTER TABLE #{quote_table_name(table_name)} #{fragment}"
end
end

def update_table_definition(table_name, base)
OracleEnhanced::Table.new(table_name, base)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,34 @@ class ::TestEmployee < ActiveRecord::Base; end
end
end

describe "add timestamps" do
before(:each) do
@conn = ActiveRecord::Base.connection
schema_define do
create_table :test_employees, force: true
end
class ::TestEmployee < ActiveRecord::Base; end
end

after(:each) do
schema_define do
drop_table :test_employees, if_exists: true
end
Object.send(:remove_const, "TestEmployee")
ActiveRecord::Base.clear_cache!
end

it "should add created_at and updated_at" do
expect do
@conn.add_timestamps("test_employees")
end.not_to raise_error

TestEmployee.reset_column_information
expect(TestEmployee.columns_hash["created_at"]).not_to be_nil
expect(TestEmployee.columns_hash["updated_at"]).not_to be_nil
end
end

describe "ignore options for LOB columns" do
after(:each) do
schema_define do
Expand Down
Loading