Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update add_timestamps to support 7.1 #2417

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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