Rails SQLite Delete Cascade Not Working -
Rails SQLite Delete Cascade Not Working -
where should set "pragma foreigns keys = on;" in rails 4.0?
i know it's connection setting have create rails set anytime deletes something, don't know set it. tried in database.yml in options , it's not working. can't google set it. want create cascade delete work.
the syntax this:
drop table if exists db_name.table_name where if exists , db_name. parts optional. there no cascade in there sqlite doesn't back upwards cascade when using drop table , there's nil can add together (unless, of course, want hack sqlite c source , add together yourself). have take limitations when using sqlite, 1 of them.
if want utilize 1 migration both sqlite , mysql you'll have check database beingness used , execute appropriate sql or find works everywhere (i.e. perform cascade hand). easy way check database you're using can think of right be:
case connection when activerecord::connectionadapters::postgresqladapter # postgresql things go here when activerecord::connectionadapters::abstractmysqladapter # mysql things go here when activerecord::connectionadapters::sqliteadapter # sqlite things go here ... end ruby-on-rails sqlite database-connection
Comments
Post a Comment