Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
e040b89e
Commit
e040b89e
authored
5 years ago
by
Manon Blanco
Browse files
Options
Downloads
Patches
Plain Diff
fix migration
parent
f11d0623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/documents/migrations/0030_remove_entity_metatype.py
+42
-0
42 additions, 0 deletions
arkindex/documents/migrations/0030_remove_entity_metatype.py
with
42 additions
and
0 deletions
arkindex/documents/migrations/0030_remove_entity_type
_metadata
.py
→
arkindex/documents/migrations/0030_remove_entity_
meta
type.py
+
42
−
0
View file @
e040b89e
# Generated by Django 2.2 on 2019-12-13 10:28
from
django.db
import
migrations
from
arkindex_common.
enum
s
import
MetaType
from
enum
import
Enum
def
updateMetadata
(
apps
,
schema_editor
):
values
=
set
(
item
.
value
for
item
in
MetaType
)
def
remove_entity_metatype
(
apps
,
schema_editor
):
MetaData
=
apps
.
get_model
(
'
documents
'
,
'
MetaData
'
)
for
metadata
in
MetaData
.
objects
\
.
filter
(
type
=
MetaType
.
Entity
)
\
.
prefetch_related
(
'
entity
'
):
metadata_type
=
MetaType
.
Text
class
OldMetaType
(
Enum
):
Text
=
'
text
'
HTML
=
'
html
'
Date
=
'
date
'
Location
=
'
location
'
Reference
=
'
reference
'
Entity
=
'
entity
'
values
=
set
(
item
.
value
for
item
in
OldMetaType
)
# Don't try this at home
MetaData
.
_meta
.
fields
[
2
].
enum
=
OldMetaType
for
metadata
in
MetaData
.
objects
.
filter
(
type
=
OldMetaType
.
Entity
).
prefetch_related
(
'
entity
'
):
metadata_type
=
OldMetaType
.
Text
if
metadata
.
entity
and
metadata
.
entity
.
type
.
value
in
values
:
metadata_type
=
MetaType
(
metadata
.
entity
.
type
.
value
)
metadata_type
=
Old
MetaType
(
metadata
.
entity
.
type
.
value
)
metadata
.
type
=
metadata_type
metadata
.
save
()
...
...
@@ -24,5 +35,8 @@ class Migration(migrations.Migration):
]
operations
=
[
migrations
.
RunPython
(
updateMetadata
,
migrations
.
RunPython
.
noop
),
migrations
.
RunPython
(
remove_entity_metatype
,
reverse_code
=
migrations
.
RunPython
.
noop
),
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment