trabajo-afectivo/db/migrate/20170419000001_ldap_support.rb

109 lines
2.9 KiB
Ruby
Raw Permalink Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
2017-09-08 08:28:34 +00:00
class LdapSupport < ActiveRecord::Migration[4.2]
def up
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
2017-04-19 13:00:51 +00:00
if !ActiveRecord::Base.connection.table_exists? 'import_jobs'
create_table :import_jobs do |t|
t.string :name, limit: 250, null: false
2017-04-19 13:00:51 +00:00
t.boolean :dry_run, default: false
2017-04-19 13:00:51 +00:00
t.text :payload, limit: 80_000
t.text :result, limit: 80_000
t.datetime :started_at # rubocop:disable Zammad/ExistsDateTimePrecision
t.datetime :finished_at # rubocop:disable Zammad/ExistsDateTimePrecision
t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
2017-04-19 13:00:51 +00:00
end
end
Setting.create_or_update(
title: 'Authentication via %s',
name: 'auth_ldap',
area: 'Security::Authentication',
description: 'Enables user authentication via %s.',
preferences: {
title_i18n: ['LDAP'],
description_i18n: ['LDAP'],
permission: ['admin.security'],
},
state: {
adapter: 'Auth::Ldap',
2017-11-23 08:09:44 +00:00
login_attributes: %w[login email],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'LDAP integration',
name: 'ldap_integration',
area: 'Integration::Switch',
description: 'Defines if LDAP is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'ldap_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
authentication: true,
permission: ['admin.integration'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'LDAP config',
name: 'ldap_config',
area: 'Integration::LDAP',
description: 'Defines the LDAP config.',
options: {},
state: {},
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Scheduler.create_or_update(
name: 'Import Jobs',
2017-04-19 13:00:51 +00:00
method: 'ImportJob.start_registered',
period: 1.hour,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1
)
2017-04-19 13:00:51 +00:00
Setting.create_if_not_exists(
title: 'Import Backends',
name: 'import_backends',
area: 'Import',
description: 'A list of active import backends that get scheduled automatically.',
options: {},
state: ['Import::Ldap'],
preferences: {
permission: ['admin'],
},
frontend: false
2017-04-19 13:00:51 +00:00
)
end
end