Ajout d'une source pour les MetadataMapping

Ça aidera à faire du nettoyage, par exemple sur ce qui vient 
automatiquement de LDAP.
This commit is contained in:
Jérémy Lecour 2021-01-16 18:01:11 +01:00 committed by Jérémy Lecour
parent 02a51121e3
commit f991f5d35b
3 changed files with 11 additions and 5 deletions

View file

@ -0,0 +1,5 @@
class AddSourceToMetadataMappings < ActiveRecord::Migration[6.1]
def change
add_column :metadata_mappings, :source, :string, limit: 20
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_01_06_221142) do
ActiveRecord::Schema.define(version: 2021_01_16_165351) do
create_table "action_mailbox_inbound_emails", force: :cascade do |t|
t.integer "status", default: 0, null: false
@ -73,6 +73,7 @@ ActiveRecord::Schema.define(version: 2021_01_06_221142) do
t.string "entity"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "source", limit: 20
t.index ["input"], name: "index_metadata_mappings_on_input"
end

View file

@ -55,10 +55,10 @@ namespace :metadata_mappings do
end
metadata.each do |input, meta|
mapping = MetadataMapping.find_or_initialize_by(input: input) { |record|
record.server = meta[:server]
record.entity = meta[:entity]
}
mapping = MetadataMapping.find_or_initialize_by(input: input)
mapping.server = meta[:server]
mapping.entity = meta[:entity]
mapping.source = :ldap
mapping.save
end