Cross Reference: 20160310132618_enter_name_for_mappings.rb
xref
: /
ontohub
/
db
/
migrate
/
20160310132618_enter_name_for_mappings.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
20160310132618_enter_name_for_mappings.rb revision 5a102b3c56d4ac75632c7e9244ee0ce5bdbbf13a
class
EnterNameForMappings
<
MigrationWithData
def
up
Mapping.where
(
name
:
nil
)
.
select
(:
id
)
.
find_each
do
|
mapping
|
iri
=
select_attributes
(
mapping
, :
iri
)
[:
iri
]
linkid
=
iri.split
(
'?'
)
.
last
if
linkid
!=
iri
update_columns
(
mapping
,
name
:
"mapping-#{linkid}"
)
else
update_columns
(
mapping
,
name
:
"mapping-#{
mapping.id
}"
)
end
end
end
def
down
# Nothing to do because missing data was generated.
end
end