SQLite Forum

Bug in ALTER TABLE ADD COLUMN
Login
This matters in practice for Ruby on Rails users, because it causes certain database migrations to fail. 

Whether this is a Rails problem or a SQLite problem (or not a problem at all) I guess is a matter of interpretation. I'm posting here to open the discussion, so that hopefully we can figure out the most appropriate place to fix this behavior. 

I've opened a discussion on the Rails Github issues again:  
[Github issues](https://github.com/rails/rails/issues/37858)

The real use case would be to allow users of Rails to add reference columns using the same interface as other SQL databases. As is, we run into this error and it feels somewhat mysterious because Rails' ActiveRecord ORM tries to present a consistent interface for SQLite/postgres/MySQL. 

I acknowledge that various workarounds are possible, but Rails discourages manually editing database schemas. Forcing users to manually edit the schema means that SQLite is being treated differently, and is more complex to use, than other database back-ends. 

If SQLite was some obscure, special-purpose database, I think a workaround would make more sense. But it's being used as the 'development' database in Rails 6 by default, so it's the first one that most users are going to have experience with. It's kind of jarring to create a new Rails project, try adding a reference column, then bam... you're 1 step beyond the tutorial and you're diving through layers to understand what's happening.

It would be interesting if someone here could comment. Do you see this as: 
 
 * A Rails problem  
 * A SQlite problem  
 * Not a problem  
 * A problem between interfaces which is minor and shouldn't be fixed