error in sqlite3 #14

yangjiandong opened this Issue Jan 16, 2011 · 4 comments


None yet
4 participants

use jruby1.6rc1,rails3.0.1,activerecord-jdbcsqlite3-adapter,in migrate use:
ActsAsArchive.update Post
it show:
AlsoMigrate error: ActiveRecord::JDBCError: near "LIKE": syntax error:
CREATE TABLE archived_posts LIKE posts;

echarp commented Jan 16, 2011

It seems you need to add parenthesis around the sql "like xxx".

It's related to "also_migrate", see

It seems that:

is not supported by sqlite. I also see this sqlite related commit from a fork

Putting parens around the like clause allows the migration to proceed, but my schema.rb ends ups with the following comment:

# Could not dump table "archived_apps" because of following StandardError
#   Unknown type 'apps' for column 'LIKE'

Looking at the database itself, I see that sqlite is treating LIKE as a column name:

sqlite> select * from sqlite_master where name = 'archived_apps';
select * from sqlite_master where name = 'archived_apps';
table|archived_apps|archived_apps|45|CREATE TABLE archived_apps
                  (LIKE apps, "deleted_at" datetime)

This problem is not specific to jruby as my development environment is a stock rails 3.0.3 project.

It seems very odd that this projects seems fairly sophisticated and somewhat mature yet fails so miserably out of the box. How could this not work in the default rails dev environment? Seems like I must be missing something.

Any hints would be fabulous.

Looking at the code more closely, I worked around the borked table creation by specifying the :indexes option:
acts_as_archive :indexes => [:id]
which forces the code through a slightly different path to make it work.

Now the migration will actually create the archive tables, but the next problem is that records are deleted from the origin table and never actually created in the archive table.


winton commented Jan 20, 2011

Hey guys, thanks for looking into this. I am going to look into getting the specs running in SQLite this weekend. If anybody makes it there before me, it would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment