change_column :people, :dob, :date -- what command will the adapter generate if the field was originally datetime?

9 views
Skip to first unread message

Michael McGrath

unread,
Nov 15, 2012, 3:54:09 PM11/15/12
to oracle-...@googlegroups.com
Hi
we have a system deployed on both MySQL and Oracle back-ends. There's a field in people called dob which has, for dull historical reasons, been a datetime. We want to change this to be a date.

What SQL command will be sent to Oracle if a change_column in included in a migration -- or will the Oracle Adapter ignore it on the basis that it isn't actually a schema change in Oracle as the column will still be DATE?

Michael

Yasuo Honda

unread,
Nov 15, 2012, 5:38:38 PM11/15/12
to oracle-...@googlegroups.com
Just create a sample code below and it looks change_column
executes alter table statements.

Actually, nothing changed at Oracle database point of view.

```ruby
schema_define do
create_table :test_posts, :force => true do |t|
t.string :title, :null => false
t.datetime :dob
end
end
```

```ruby
it "foobar" do
schema_define do
change_column :test_posts, :dob, :date
end
end
```ruby


```sql
CREATE TABLE "TEST_POSTS" ("ID" NUMBER(38) NOT NULL PRIMARY KEY,
"TITLE" VARCHAR2(255) NOT NULL, "DOB" DATE
)
ALTER TABLE "TEST_POSTS" MODIFY "DOB" DATE
```

--
Yasuo Honda
> --
> You received this message because you are subscribed to the Google Groups
> "Oracle enhanced adapter for ActiveRecord" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/oracle-enhanced/-/QHPn-0PlWpUJ.
> To post to this group, send email to oracle-...@googlegroups.com.
> To unsubscribe from this group, send email to
> oracle-enhanc...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/oracle-enhanced?hl=en.
Reply all
Reply to author
Forward
0 new messages