|
1
|
|
|
"""init |
|
2
|
|
|
|
|
3
|
|
|
Revision ID: 3924a7ad2f8 |
|
4
|
|
|
Revises: None |
|
5
|
|
|
Create Date: 2014-04-10 15:37:26.804103 |
|
6
|
|
|
|
|
7
|
|
|
""" |
|
8
|
|
|
import sqlalchemy as sa |
|
9
|
|
|
from alembic import op |
|
10
|
|
|
|
|
11
|
|
|
# revision identifiers, used by Alembic. |
|
12
|
|
|
revision = '3924a7ad2f8' |
|
13
|
|
|
down_revision = None |
|
14
|
|
|
branch_labels = ('atramhasis',) |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
def upgrade(): |
|
19
|
|
|
### commands auto generated by Alembic - please adjust! ### |
|
20
|
|
|
op.create_table('labeltype', |
|
21
|
|
|
sa.Column('name', sa.String(length=20), nullable=False), |
|
22
|
|
|
sa.Column('description', sa.Text(), nullable=True), |
|
23
|
|
|
sa.PrimaryKeyConstraint('name') |
|
24
|
|
|
) |
|
25
|
|
|
op.create_table('language', |
|
26
|
|
|
sa.Column('id', sa.String(length=64), nullable=False), |
|
27
|
|
|
sa.Column('name', sa.String(length=255), nullable=True), |
|
28
|
|
|
sa.PrimaryKeyConstraint('id') |
|
29
|
|
|
) |
|
30
|
|
|
op.create_table('conceptscheme', |
|
31
|
|
|
sa.Column('id', sa.Integer(), nullable=False), |
|
32
|
|
|
sa.Column('uri', sa.String(length=512), nullable=True), |
|
33
|
|
|
sa.PrimaryKeyConstraint('id') |
|
34
|
|
|
) |
|
35
|
|
|
op.create_table('notetype', |
|
36
|
|
|
sa.Column('name', sa.String(length=20), nullable=False), |
|
37
|
|
|
sa.Column('description', sa.Text(), nullable=True), |
|
38
|
|
|
sa.PrimaryKeyConstraint('name') |
|
39
|
|
|
) |
|
40
|
|
|
op.create_table('label', |
|
41
|
|
|
sa.Column('id', sa.Integer(), nullable=False), |
|
42
|
|
|
sa.Column('label', sa.String(length=512), nullable=False), |
|
43
|
|
|
sa.Column('labeltype_id', sa.String(length=20), nullable=False), |
|
44
|
|
|
sa.Column('language_id', sa.String(length=64), nullable=True), |
|
45
|
|
|
sa.ForeignKeyConstraint(['labeltype_id'], ['labeltype.name'], ), |
|
46
|
|
|
sa.ForeignKeyConstraint(['language_id'], ['language.id'], ), |
|
47
|
|
|
sa.PrimaryKeyConstraint('id') |
|
48
|
|
|
) |
|
49
|
|
|
op.create_index('ix_label_labeltype_id', 'label', ['labeltype_id'], unique=False) |
|
50
|
|
|
op.create_index('ix_label_language_id', 'label', ['language_id'], unique=False) |
|
51
|
|
|
op.create_table('note', |
|
52
|
|
|
sa.Column('id', sa.Integer(), nullable=False), |
|
53
|
|
|
sa.Column('note', sa.Text(), nullable=False), |
|
54
|
|
|
sa.Column('notetype_id', sa.String(length=20), nullable=False), |
|
55
|
|
|
sa.Column('language_id', sa.String(length=64), nullable=True), |
|
56
|
|
|
sa.ForeignKeyConstraint(['language_id'], ['language.id'], ), |
|
57
|
|
|
sa.ForeignKeyConstraint(['notetype_id'], ['notetype.name'], ), |
|
58
|
|
|
sa.PrimaryKeyConstraint('id') |
|
59
|
|
|
) |
|
60
|
|
|
op.create_index('ix_note_language_id', 'note', ['language_id'], unique=False) |
|
61
|
|
|
op.create_index('ix_note_notetype_id', 'note', ['notetype_id'], unique=False) |
|
62
|
|
|
op.create_table('concept', |
|
63
|
|
|
sa.Column('id', sa.Integer(), nullable=False), |
|
64
|
|
|
sa.Column('type', sa.String(length=30), nullable=True), |
|
65
|
|
|
sa.Column('concept_id', sa.Integer(), nullable=False), |
|
66
|
|
|
sa.Column('uri', sa.String(length=512), nullable=True), |
|
67
|
|
|
sa.Column('conceptscheme_id', sa.Integer(), nullable=False), |
|
68
|
|
|
sa.ForeignKeyConstraint(['conceptscheme_id'], ['conceptscheme.id'], ), |
|
69
|
|
|
sa.PrimaryKeyConstraint('id') |
|
70
|
|
|
) |
|
71
|
|
|
op.create_index('ix_concept_concept_id', 'concept', ['concept_id'], unique=False) |
|
72
|
|
|
op.create_index('ix_concept_conceptscheme_id', 'concept', ['conceptscheme_id'], unique=False) |
|
73
|
|
|
op.create_table('collection_concept', |
|
74
|
|
|
sa.Column('collection_id', sa.Integer(), nullable=False), |
|
75
|
|
|
sa.Column('concept_id', sa.Integer(), nullable=False), |
|
76
|
|
|
sa.ForeignKeyConstraint(['collection_id'], ['concept.id'], ), |
|
77
|
|
|
sa.ForeignKeyConstraint(['concept_id'], ['concept.id'], ), |
|
78
|
|
|
sa.PrimaryKeyConstraint('collection_id', 'concept_id') |
|
79
|
|
|
) |
|
80
|
|
|
op.create_table('conceptscheme_note', |
|
81
|
|
|
sa.Column('conceptscheme_id', sa.Integer(), nullable=False), |
|
82
|
|
|
sa.Column('note_id', sa.Integer(), nullable=False), |
|
83
|
|
|
sa.ForeignKeyConstraint(['conceptscheme_id'], ['conceptscheme.id'], ), |
|
84
|
|
|
sa.ForeignKeyConstraint(['note_id'], ['note.id'], ), |
|
85
|
|
|
sa.PrimaryKeyConstraint('conceptscheme_id', 'note_id') |
|
86
|
|
|
) |
|
87
|
|
|
op.create_table('conceptscheme_label', |
|
88
|
|
|
sa.Column('conceptscheme_id', sa.Integer(), nullable=False), |
|
89
|
|
|
sa.Column('label_id', sa.Integer(), nullable=False), |
|
90
|
|
|
sa.ForeignKeyConstraint(['conceptscheme_id'], ['conceptscheme.id'], ), |
|
91
|
|
|
sa.ForeignKeyConstraint(['label_id'], ['label.id'], ), |
|
92
|
|
|
sa.PrimaryKeyConstraint('conceptscheme_id', 'label_id') |
|
93
|
|
|
) |
|
94
|
|
|
op.create_table('visitation', |
|
95
|
|
|
sa.Column('id', sa.Integer(), nullable=False), |
|
96
|
|
|
sa.Column('lft', sa.Integer(), nullable=False), |
|
97
|
|
|
sa.Column('rght', sa.Integer(), nullable=False), |
|
98
|
|
|
sa.Column('depth', sa.Integer(), nullable=False), |
|
99
|
|
|
sa.Column('conceptscheme_id', sa.Integer(), nullable=False), |
|
100
|
|
|
sa.Column('concept_id', sa.Integer(), nullable=False), |
|
101
|
|
|
sa.ForeignKeyConstraint(['concept_id'], ['concept.id'], ), |
|
102
|
|
|
sa.ForeignKeyConstraint(['conceptscheme_id'], ['conceptscheme.id'], ), |
|
103
|
|
|
sa.PrimaryKeyConstraint('id') |
|
104
|
|
|
) |
|
105
|
|
|
op.create_index('ix_visitation_concept_id', 'visitation', ['concept_id'], unique=False) |
|
106
|
|
|
op.create_index('ix_visitation_conceptscheme_id', 'visitation', ['conceptscheme_id'], unique=False) |
|
107
|
|
|
op.create_index('ix_visitation_depth', 'visitation', ['depth'], unique=False) |
|
108
|
|
|
op.create_index('ix_visitation_lft', 'visitation', ['lft'], unique=False) |
|
109
|
|
|
op.create_index('ix_visitation_rght', 'visitation', ['rght'], unique=False) |
|
110
|
|
|
op.create_table('concept_note', |
|
111
|
|
|
sa.Column('concept_id', sa.Integer(), nullable=False), |
|
112
|
|
|
sa.Column('note_id', sa.Integer(), nullable=False), |
|
113
|
|
|
sa.ForeignKeyConstraint(['concept_id'], ['concept.id'], ), |
|
114
|
|
|
sa.ForeignKeyConstraint(['note_id'], ['note.id'], ), |
|
115
|
|
|
sa.PrimaryKeyConstraint('concept_id', 'note_id') |
|
116
|
|
|
) |
|
117
|
|
|
op.create_table('concept_related_concept', |
|
118
|
|
|
sa.Column('concept_id_from', sa.Integer(), nullable=False), |
|
119
|
|
|
sa.Column('concept_id_to', sa.Integer(), nullable=False), |
|
120
|
|
|
sa.ForeignKeyConstraint(['concept_id_from'], ['concept.id'], ), |
|
121
|
|
|
sa.ForeignKeyConstraint(['concept_id_to'], ['concept.id'], ), |
|
122
|
|
|
sa.PrimaryKeyConstraint('concept_id_from', 'concept_id_to') |
|
123
|
|
|
) |
|
124
|
|
|
op.create_table('concept_hierarchy_concept', |
|
125
|
|
|
sa.Column('concept_id_broader', sa.Integer(), nullable=False), |
|
126
|
|
|
sa.Column('concept_id_narrower', sa.Integer(), nullable=False), |
|
127
|
|
|
sa.ForeignKeyConstraint(['concept_id_broader'], ['concept.id'], ), |
|
128
|
|
|
sa.ForeignKeyConstraint(['concept_id_narrower'], ['concept.id'], ), |
|
129
|
|
|
sa.PrimaryKeyConstraint('concept_id_broader', 'concept_id_narrower') |
|
130
|
|
|
) |
|
131
|
|
|
op.create_table('concept_hierarchy_collection', |
|
132
|
|
|
sa.Column('concept_id_broader', sa.Integer(), nullable=False), |
|
133
|
|
|
sa.Column('collection_id_narrower', sa.Integer(), nullable=False), |
|
134
|
|
|
sa.ForeignKeyConstraint(['collection_id_narrower'], ['concept.id'], ), |
|
135
|
|
|
sa.ForeignKeyConstraint(['concept_id_broader'], ['concept.id'], ), |
|
136
|
|
|
sa.PrimaryKeyConstraint('concept_id_broader', 'collection_id_narrower') |
|
137
|
|
|
) |
|
138
|
|
|
op.create_table('concept_label', |
|
139
|
|
|
sa.Column('concept_id', sa.Integer(), nullable=False), |
|
140
|
|
|
sa.Column('label_id', sa.Integer(), nullable=False), |
|
141
|
|
|
sa.ForeignKeyConstraint(['concept_id'], ['concept.id'], ), |
|
142
|
|
|
sa.ForeignKeyConstraint(['label_id'], ['label.id'], ), |
|
143
|
|
|
sa.PrimaryKeyConstraint('concept_id', 'label_id') |
|
144
|
|
|
) |
|
145
|
|
|
### end Alembic commands ### |
|
146
|
|
|
|
|
147
|
|
|
|
|
148
|
|
|
def downgrade(): |
|
149
|
|
|
### commands auto generated by Alembic - please adjust! ### |
|
150
|
|
|
op.drop_table('concept_label') |
|
151
|
|
|
op.drop_table('concept_hierarchy_collection') |
|
152
|
|
|
op.drop_table('concept_hierarchy_concept') |
|
153
|
|
|
op.drop_table('concept_related_concept') |
|
154
|
|
|
op.drop_table('concept_note') |
|
155
|
|
|
op.drop_index('ix_visitation_rght', table_name='visitation') |
|
156
|
|
|
op.drop_index('ix_visitation_lft', table_name='visitation') |
|
157
|
|
|
op.drop_index('ix_visitation_depth', table_name='visitation') |
|
158
|
|
|
op.drop_index('ix_visitation_conceptscheme_id', table_name='visitation') |
|
159
|
|
|
op.drop_index('ix_visitation_concept_id', table_name='visitation') |
|
160
|
|
|
op.drop_table('visitation') |
|
161
|
|
|
op.drop_table('conceptscheme_label') |
|
162
|
|
|
op.drop_table('conceptscheme_note') |
|
163
|
|
|
op.drop_table('collection_concept') |
|
164
|
|
|
op.drop_index('ix_concept_conceptscheme_id', table_name='concept') |
|
165
|
|
|
op.drop_index('ix_concept_concept_id', table_name='concept') |
|
166
|
|
|
op.drop_table('concept') |
|
167
|
|
|
op.drop_index('ix_note_notetype_id', table_name='note') |
|
168
|
|
|
op.drop_index('ix_note_language_id', table_name='note') |
|
169
|
|
|
op.drop_table('note') |
|
170
|
|
|
op.drop_index('ix_label_language_id', table_name='label') |
|
171
|
|
|
op.drop_index('ix_label_labeltype_id', table_name='label') |
|
172
|
|
|
op.drop_table('label') |
|
173
|
|
|
op.drop_table('notetype') |
|
174
|
|
|
op.drop_table('conceptscheme') |
|
175
|
|
|
op.drop_table('language') |
|
176
|
|
|
op.drop_table('labeltype') |
|
177
|
|
|
### end Alembic commands ### |
|
178
|
|
|
|