# SQLite3 put a parse error in my schema.rb for timestamps

**URL:** <https://www.ruby-forum.com/t/sqlite3-put-a-parse-error-in-my-schema-rb-for-timestamps/76348>\
**Category:** Rails\
**Created:** [November 17, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/sqlite3-put-a-parse-error-in-my-schema-rb-for-timestamps/76348 "2006-11-17T19:17:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [November 17, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/sqlite3-put-a-parse-error-in-my-schema-rb-for-timestamps/76348/1 "2006-11-17T19:17:00Z")

</div>

Railsers:

I switched from MySQL to Sqlite3 for Test-Driven Development. It meant  
the difference between

(Long term, I want to understand the db:migrate system well enough  
that I can run a long test, occassionally, that migrates everything to  
MySQL and retests it there. That will prevent nasty surprises at  
deployment time. But that’s not the current question!)

Because I don’t lean on db:migrate yet, I start the cycle by keeping a  
file, db/create.sql, and if it upgrades, then my tests run it in the  
database to create the schema. So the table contains goodies like  
these:

drop table chats;

create table chats (  
id integer primary key, – auto\_increment,  
user\_id integer not null,  
panel\_id integer not null,  
uttered\_at timestamp DEFAULT CURRENT\_TIMESTAMP,  
utterance varchar(255) not null  
);

(Note, for example, that MySQL will [sometimes] require the  
auto\_increment, but SQLite can’t use it.)

Now note the timestamp DEFAULT CURRENT\_TIMESTAMP. That’s because I’m  
too lazy to write Time.now inside the model code for the Chat object.  
I want the database itself to take care of low-level details.

But something is migrating that schema back into schema.rb looking like  
this:

create\_table “chats”, :force =\> true do |t|  
t.column “user\_id”, :integer, :null =\> false  
t.column “panel\_id”, :integer, :null =\> false  
t.column “uttered\_at”, :timestamp, :default =\> Fri Nov 17 18:03:40  
-0800 2006  
t.column “utterance”, :string, :null =\> false  
end

Notice :default =\> points to a timestamp that’s A\> not in :db format,  
and B\> isn’t a string. This causes a big cascade of silly syntax  
errors.

What is Rails (or, possibly, me) doing wrong?

–  
Phlip  
[http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [November 17, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/sqlite3-put-a-parse-error-in-my-schema-rb-for-timestamps/76348/2 "2006-11-17T19:23:02Z")

</div>

> I switched from MySQL to Sqlite3 for Test-Driven Development. It meant  
> the difference between

2 minutes and 8 seconds for a short batch of lean functional tests.
