Commit 4359949d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix_broken_migration' into 'master'

Fix broken migration

See merge request !233
parents 34c241e1 e45d5f7f
......@@ -4,16 +4,10 @@ class RenameLdapGroupToLdapGroupLink < ActiveRecord::Migration
# NOTE: we use the old_ methods because the new methods are overloaded
# for backwards compatibility
Group.where.not(ldap_cn: nil).each do |group|
# Make sure we use the database column, not the model methods
ldap_cn = group.read_attribute(:ldap_cn)
ldap_access = group.read_attribute(:ldap_access)
group.ldap_group_links.where(cn: ldap_cn).first_or_create do |ldap_group_link|
ldap_group_link.group_access = ldap_access
end
end
time = Time.now.strftime('%Y-%m-%d %H:%M:%S')
execute "INSERT INTO ldap_group_links ( group_access, cn, group_id, created_at, updated_at )
SELECT ldap_access, ldap_cn, id, DATE('#{time}'), DATE('#{time}') FROM namespaces
WHERE ldap_cn IS NOT NULL;"
end
def down
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment