1
|
|
|
"""add skos matches |
2
|
|
|
|
3
|
|
|
Revision ID: 441c5a16ef8 |
4
|
|
|
Revises: 4f1ee5c9c08 |
5
|
|
|
Create Date: 2014-10-24 11:04:10.310845 |
6
|
|
|
|
7
|
|
|
""" |
8
|
|
|
import sqlalchemy as sa |
9
|
|
|
from alembic import op |
10
|
|
|
from sqlalchemy.sql import column |
11
|
|
|
from sqlalchemy.sql import table |
12
|
|
|
|
13
|
|
|
# revision identifiers, used by Alembic. |
14
|
|
|
revision = "441c5a16ef8" |
15
|
|
|
down_revision = "4f1ee5c9c08" |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
def upgrade(): |
19
|
|
|
op.create_table( |
20
|
|
|
"matchtype", |
21
|
|
|
sa.Column("name", sa.String(length=20), nullable=False, primary_key=True), |
22
|
|
|
sa.Column("description", sa.Text(), nullable=True), |
23
|
|
|
) |
24
|
|
|
op.create_table( |
25
|
|
|
"match", |
26
|
|
|
sa.Column("uri", sa.String(length=512), nullable=False), |
27
|
|
|
sa.Column("concept_id", sa.Integer, nullable=False), |
28
|
|
|
sa.Column("matchtype_id", sa.String(length=20), nullable=False), |
29
|
|
|
sa.ForeignKeyConstraint( |
30
|
|
|
["concept_id"], |
31
|
|
|
["concept.id"], |
32
|
|
|
), |
33
|
|
|
sa.ForeignKeyConstraint( |
34
|
|
|
["matchtype_id"], |
35
|
|
|
["matchtype.name"], |
36
|
|
|
), |
37
|
|
|
sa.PrimaryKeyConstraint("uri", "concept_id", "matchtype_id"), |
38
|
|
|
) |
39
|
|
|
op.bulk_insert( |
40
|
|
|
table( |
41
|
|
|
"matchtype", |
42
|
|
|
column("name", sa.String), |
43
|
|
|
column("description", sa.Text), |
44
|
|
|
), |
45
|
|
|
[ |
46
|
|
|
{ |
47
|
|
|
"name": "closeMatch", |
48
|
|
|
"description": "Indicates that two concepts are sufficiently similar that they can be used interchangeably in some information retrieval applications.", |
49
|
|
|
}, |
50
|
|
|
{ |
51
|
|
|
"name": "exactMatch", |
52
|
|
|
"description": "Indicates that there is a high degree of confidence that two concepts can be used interchangeably across a wide range of information retrieval applications.", |
53
|
|
|
}, |
54
|
|
|
{ |
55
|
|
|
"name": "broadMatch", |
56
|
|
|
"description": "Indicates that one concept has a broader match with another one.", |
57
|
|
|
}, |
58
|
|
|
{ |
59
|
|
|
"name": "narrowMatch", |
60
|
|
|
"description": "Indicates that one concept has a narrower match with another one.", |
61
|
|
|
}, |
62
|
|
|
{ |
63
|
|
|
"name": "relatedMatch", |
64
|
|
|
"description": "Indicates that there is an associative mapping between two concepts.", |
65
|
|
|
}, |
66
|
|
|
], |
67
|
|
|
) |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
def downgrade(): |
71
|
|
|
op.drop_table("match") |
72
|
|
|
op.drop_table("matchtype") |
73
|
|
|
|