mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 00:36:14 +02:00
Delete orphaned query and role ids from habtm join table (#36844).
git-svn-id: https://svn.redmine.org/redmine/trunk@21893 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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
|
||||
Reference in New Issue
Block a user