Skip to content

Instantly share code, notes, and snippets.

@abargnesi
Created August 6, 2014 18:26
Show Gist options
  • Save abargnesi/72be7fcb7009adb82e14 to your computer and use it in GitHub Desktop.
Save abargnesi/72be7fcb7009adb82e14 to your computer and use it in GitHub Desktop.
Fail to migrate using sqlite database...SQL compliant ALTER syntax?
[tony@starship openbel-webtools (master * u=)]$ rm db/development.sqlite3
[tony@starship openbel-webtools (master * u=)]$ rm db/test.sqlite3
[tony@starship openbel-webtools (master * u=)]$ rake db:setup
-- create_table("belfiles", {:force=>true})
-> 0.0494s
-- initialize_schema_migrations_table()
-> 0.1396s
You have 3 pending migrations:
20140806032021 CreateGraphs
20140806032038 CreateNodes
20140806032047 CreateEdges
Run `rake db:migrate` to update your database then try again.
[tony@starship openbel-webtools (master * u=)]$ rake db:migrate
== 20140806032021 CreateGraphs: migrating =====================================
-- create_table(:graphs)
-> 0.0054s
-- add_index(:graphs, :belfile_id)
-> 0.0007s
-- execute(" ALTER TABLE graphs\n ADD CONSTRAINT fk_graph_belfile\n FOREIGN KEY (belfile_id)\n REFERENCES belfiles(id)\n")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: near "CONSTRAINT": syntax error: ALTER TABLE graphs
ADD CONSTRAINT fk_graph_belfile
FOREIGN KEY (belfile_id)
REFERENCES belfiles(id)
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:13:in `block (2 levels) in change'
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:11:in `block in change'
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:10:in `change'
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "CONSTRAINT": syntax error: ALTER TABLE graphs
ADD CONSTRAINT fk_graph_belfile
FOREIGN KEY (belfile_id)
REFERENCES belfiles(id)
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:13:in `block (2 levels) in change'
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:11:in `block in change'
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:10:in `change'
SQLite3::SQLException: near "CONSTRAINT": syntax error
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:13:in `block (2 levels) in change'
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:11:in `block in change'
/home/tony/work/repos/openbel-webtools/db/migrate/20140806032021_create_graphs.rb:10:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment