Add ldap_groups

parent 22b0b2b4
......@@ -21,6 +21,7 @@ class Group < Namespace
has_many :users, through: :users_groups
has_many :project_group_links, dependent: :destroy
has_many :shared_projects, through: :project_group_links, source: :project
has_many :ldap_groups, foreign_key: 'group_id'
validates :ldap_access,
inclusion: { in: UsersGroup.group_access_roles.values },
......
class LdapGroup < ActiveRecord::Base
belongs_to :group
validates :cn, uniqueness: { scope: :group_id }
end
class AddLdapGroupsTable < ActiveRecord::Migration
def up
create_table :ldap_groups do |t|
t.string :cn, null: false
t.integer :group_access, null: false
t.references :group, null: false
t.timestamps
end
Group.where.not(ldap_cn: nil).each do |group|
group.ldap_groups.where(cn: group.ldap_cn).first_or_create do |ldap_group|
ldap_group.group_access = group.ldap_access
end
end
end
def down
drop_table :ldap_groups
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140811155127) do
ActiveRecord::Schema.define(version: 20140813090117) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -128,6 +128,14 @@ ActiveRecord::Schema.define(version: 20140811155127) do
add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree
create_table "ldap_groups", force: true do |t|
t.string "cn", null: false
t.integer "group_access", null: false
t.integer "group_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "merge_request_diffs", force: true do |t|
t.string "state"
t.text "st_commits"
......@@ -137,8 +145,6 @@ ActiveRecord::Schema.define(version: 20140811155127) do
t.datetime "updated_at"
end
add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", unique: true, using: :btree
create_table "merge_requests", force: true do |t|
t.string "target_branch", null: false
t.string "source_branch", null: false
......
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