You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1234567891011121314 |
- class DeleteOrphanedQueryAndRoleFromQueriesRoles < ActiveRecord::Migration[6.1]
- def self.up
- queries_roles = "#{Query.table_name_prefix}queries_roles#{Query.table_name_suffix}"
- queries = Query.table_name
- roles = Role.table_name
-
- ActiveRecord::Base.connection.execute "DELETE FROM #{queries_roles} WHERE query_id NOT IN (SELECT DISTINCT(id) FROM #{queries})"
- ActiveRecord::Base.connection.execute "DELETE FROM #{queries_roles} WHERE role_id NOT IN (SELECT DISTINCT(id) FROM #{roles})"
- end
-
- def self.down
- # no-op
- end
- end
|