views:

37

answers:

2

If I change the type of a field in my database via a Ruby on Rails migration, from string to text, will I lose the data in the field?

+6  A: 

As far as I remember, SQLite uses the type only for input/output. Internally, everything is stored as text (that's why you can also store text in an int-field if you want). So no, it shouldn't remove any data, because it's only a superficial change.

No guarantees though, it's been a while since since I last worked with SQLite ;-)

This page explains SQLite's typing system nicely.

pableu
+1  A: 

You will not lose data. String and text in SQLite are the same. There are really only five types in SQLite (NULL, INTEGER, REAL, TEXT, BLOB). Even if your field originally contained binary data (BLOB) and the database type was changed to TEXT the data is unchanged unless you store new data.

Pete