-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from Muster-Suchen-und-Erkennen/dev
Merge dev changes into master
- Loading branch information
Showing
29 changed files
with
553 additions
and
36 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
migrations/versions/084b2e29df90_.py → ...sions/084b2e29df90_more_taxonomy_lists.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
"""Add specifications | ||
Revision ID: 2bdc4cdc23a5 | ||
Revises: 084b2e29df90 | ||
Create Date: 2024-01-25 15:29:30.564815 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '2bdc4cdc23a5' | ||
down_revision = '084b2e29df90' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
spezifikation_anteil = op.create_table('spezifikation_anteil', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(length=120), nullable=True), | ||
sa.Column('description', sa.Text(), nullable=True), | ||
sa.PrimaryKeyConstraint('id', name=op.f('pk_spezifikation_anteil')) | ||
) | ||
spezifikation_auftreten = op.create_table('spezifikation_auftreten', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(length=120), nullable=True), | ||
sa.Column('description', sa.Text(), nullable=True), | ||
sa.PrimaryKeyConstraint('id', name=op.f('pk_spezifikation_auftreten')) | ||
) | ||
spezifikation_instrument = op.create_table('spezifikation_instrument', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('parent_id', sa.Integer(), nullable=True), | ||
sa.Column('name', sa.String(length=120), nullable=True), | ||
sa.Column('description', sa.Text(), nullable=True), | ||
sa.ForeignKeyConstraint(['parent_id'], ['spezifikation_instrument.id'], name=op.f('fk_spezifikation_instrument_parent_id_spezifikation_instrument'), ondelete='CASCADE'), | ||
sa.PrimaryKeyConstraint('id', name=op.f('pk_spezifikation_instrument')) | ||
) | ||
op.create_table('part_specification', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('path', sa.Text(), nullable=True), | ||
sa.Column('parent_id', sa.Integer(), nullable=True), | ||
sa.Column('share_id', sa.Integer(), nullable=True), | ||
sa.Column('occurence_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['occurence_id'], ['spezifikation_auftreten.id'], name=op.f('fk_part_specification_occurence_id_spezifikation_auftreten')), | ||
sa.ForeignKeyConstraint(['parent_id'], ['part.id'], name=op.f('fk_part_specification_parent_id_part')), | ||
sa.ForeignKeyConstraint(['share_id'], ['spezifikation_anteil.id'], name=op.f('fk_part_specification_share_id_spezifikation_anteil')), | ||
sa.PrimaryKeyConstraint('id', name=op.f('pk_part_specification')) | ||
) | ||
op.create_table('part_spec_instrument_to_specification', | ||
sa.Column('specifications_id', sa.Integer(), nullable=False), | ||
sa.Column('spezifikation_instrument_id', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['specifications_id'], ['part_specification.id'], name=op.f('fk_part_spec_instrument_to_specification_specifications_id_part_specification')), | ||
sa.ForeignKeyConstraint(['spezifikation_instrument_id'], ['spezifikation_instrument.id'], name=op.f('fk_part_spec_instrument_to_specification_spezifikation_instrument_id_spezifikation_instrument')), | ||
sa.PrimaryKeyConstraint('specifications_id', 'spezifikation_instrument_id', name=op.f('pk_part_spec_instrument_to_specification')) | ||
) | ||
op.create_table('sub_part_specification', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('path', sa.Text(), nullable=True), | ||
sa.Column('parent_id', sa.Integer(), nullable=True), | ||
sa.Column('share_id', sa.Integer(), nullable=True), | ||
sa.Column('occurence_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['occurence_id'], ['spezifikation_auftreten.id'], name=op.f('fk_sub_part_specification_occurence_id_spezifikation_auftreten')), | ||
sa.ForeignKeyConstraint(['parent_id'], ['sub_part.id'], name=op.f('fk_sub_part_specification_parent_id_sub_part')), | ||
sa.ForeignKeyConstraint(['share_id'], ['spezifikation_anteil.id'], name=op.f('fk_sub_part_specification_share_id_spezifikation_anteil')), | ||
sa.PrimaryKeyConstraint('id', name=op.f('pk_sub_part_specification')) | ||
) | ||
op.create_table('sub_part_spec_instrument_to_specification', | ||
sa.Column('specifications_id', sa.Integer(), nullable=False), | ||
sa.Column('spezifikation_instrument_id', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['specifications_id'], ['sub_part_specification.id'], name=op.f('fk_sub_part_spec_instrument_to_specification_specifications_id_sub_part_specification')), | ||
sa.ForeignKeyConstraint(['spezifikation_instrument_id'], ['spezifikation_instrument.id'], name=op.f('fk_sub_part_spec_instrument_to_specification_spezifikation_instrument_id_spezifikation_instrument')), | ||
sa.PrimaryKeyConstraint('specifications_id', 'spezifikation_instrument_id', name=op.f('pk_sub_part_spec_instrument_to_specification')) | ||
) | ||
op.create_table('voice_specification', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('path', sa.Text(), nullable=True), | ||
sa.Column('parent_id', sa.Integer(), nullable=True), | ||
sa.Column('share_id', sa.Integer(), nullable=True), | ||
sa.Column('occurence_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['occurence_id'], ['spezifikation_auftreten.id'], name=op.f('fk_voice_specification_occurence_id_spezifikation_auftreten')), | ||
sa.ForeignKeyConstraint(['parent_id'], ['voice.id'], name=op.f('fk_voice_specification_parent_id_voice')), | ||
sa.ForeignKeyConstraint(['share_id'], ['spezifikation_anteil.id'], name=op.f('fk_voice_specification_share_id_spezifikation_anteil')), | ||
sa.PrimaryKeyConstraint('id', name=op.f('pk_voice_specification')) | ||
) | ||
op.create_table('voice_spec_instrument_to_specification', | ||
sa.Column('specifications_id', sa.Integer(), nullable=False), | ||
sa.Column('spezifikation_instrument_id', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['specifications_id'], ['voice_specification.id'], name=op.f('fk_voice_spec_instrument_to_specification_specifications_id_voice_specification')), | ||
sa.ForeignKeyConstraint(['spezifikation_instrument_id'], ['spezifikation_instrument.id'], name=op.f('fk_voice_spec_instrument_to_specification_spezifikation_instrument_id_spezifikation_instrument')), | ||
sa.PrimaryKeyConstraint('specifications_id', 'spezifikation_instrument_id', name=op.f('pk_voice_spec_instrument_to_specification')) | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
# ad hoc table to query instrument taxonomy | ||
instrument = sa.table("instrument", | ||
sa.column('id', sa.Integer()), | ||
sa.column('parent_id', sa.Integer()), | ||
sa.column('name', sa.String(length=120)), | ||
sa.column('description', sa.Text()), | ||
) | ||
|
||
# if taxonomies already have values, provide values for new taxonomies as part of the migration | ||
|
||
connection = op.get_bind() | ||
|
||
# check if instrument taxonomy is populated | ||
count = connection.execute(sa.select(sa.func.count(instrument.c.id))).scalar_one_or_none() | ||
if count == 0: | ||
# taxonomies are not yet initialized, do not initialize them now | ||
return | ||
|
||
# load all instruments to add them as subtree in specification instruments taxonomy | ||
instruments_id_map = {} | ||
current_instrument_id = 6 | ||
instruments = connection.execute(sa.select(instrument)).all() | ||
for instr in instruments: | ||
if instr[2] == "root": | ||
instruments_id_map[instr[0]] = 5 # use different root in new taxonomy | ||
continue | ||
if instr[2] == "na": | ||
instruments_id_map[instr[0]] = 2 | ||
continue | ||
instruments_id_map[instr[0]] = current_instrument_id | ||
current_instrument_id += 1 | ||
|
||
# create data to insert with bulk insert | ||
extra_instruments = [] | ||
for id_, parent_id, name, description in instruments: | ||
if name in ("na", "root"): | ||
continue | ||
extra_instruments.append({ | ||
"id": instruments_id_map[id_], | ||
"parent_id": instruments_id_map[parent_id] if parent_id is not None else None, | ||
"name": name, | ||
"description": description, | ||
}) | ||
|
||
# Fill in initial data for taxonomies | ||
op.bulk_insert( | ||
spezifikation_anteil, | ||
[ | ||
{"id": 1, "name": "durchgehend", "description": ""}, | ||
{"id": 2, "name": "teilweise", "description": ""}, | ||
{"id": 3, "name": "selten", "description": ""}, | ||
] | ||
) | ||
|
||
op.bulk_insert( | ||
spezifikation_auftreten, | ||
[ | ||
{"id": 1, "name": "gegen Anfang", "description": ""}, | ||
{"id": 2, "name": "in der Mitte", "description": ""}, | ||
{"id": 3, "name": "gegen Ende", "description": ""}, | ||
] | ||
) | ||
|
||
op.bulk_insert( | ||
spezifikation_instrument, | ||
[ | ||
{"id": 1, "parent_id": None, "name": "root", "description": ""}, | ||
{"id": 2, "parent_id": None, "name": "na", "description": ""}, | ||
{"id": 3, "parent_id": 1, "name": "tutti", "description": ""}, | ||
{"id": 4, "parent_id": 1, "name": "alle Instrumente die am Werkausschnitt beteiligt sind", "description": ""}, | ||
{"id": 5, "parent_id": 1, "name": "nur folgendes besetzte Instrumente/Instrumentengruppen", "description": ""}, | ||
*extra_instruments, | ||
] | ||
) | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('voice_spec_instrument_to_specification') | ||
op.drop_table('voice_specification') | ||
op.drop_table('sub_part_spec_instrument_to_specification') | ||
op.drop_table('sub_part_specification') | ||
op.drop_table('part_spec_instrument_to_specification') | ||
op.drop_table('part_specification') | ||
op.drop_table('spezifikation_instrument') | ||
op.drop_table('spezifikation_auftreten') | ||
op.drop_table('spezifikation_anteil') | ||
# ### end Alembic commands ### |
2 changes: 1 addition & 1 deletion
2
migrations/versions/38ed909ec074_.py → ...ersions/38ed909ec074_repetition_counts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
migrations/versions/494a304bb471_.py → ...ons/494a304bb471_non_unique_opus_names.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
migrations/versions/563a2aa9584c_.py → ...rsions/563a2aa9584c_drop_tempo_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""empty message | ||
"""Drop tempo context | ||
Revision ID: 563a2aa9584c | ||
Revises: 88a8835f8310 | ||
|
2 changes: 1 addition & 1 deletion
2
migrations/versions/5d1b25e05af8_.py → migrations/versions/5d1b25e05af8_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""empty message | ||
"""Initial migration | ||
Revision ID: 5d1b25e05af8 | ||
Revises: | ||
|
2 changes: 1 addition & 1 deletion
2
migrations/versions/6332c52bf469_.py → ...ons/versions/6332c52bf469_backup_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""empty message | ||
"""Add backup table | ||
Revision ID: 6332c52bf469 | ||
Revises: 5d1b25e05af8 | ||
|
2 changes: 1 addition & 1 deletion
2
migrations/versions/638ae6935168_.py → migrations/versions/638ae6935168_refactor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""empty message | ||
"""Major refactor | ||
Revision ID: 638ae6935168 | ||
Revises: 563a2aa9584c | ||
|
2 changes: 1 addition & 1 deletion
2
migrations/versions/88a8835f8310_.py → ...ons/88a8835f8310_formal_function_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
migrations/versions/bb0693433148_.py → ...versions/bb0693433148_drop_chord_count.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""empty message | ||
"""Remove chord count from harmonics | ||
Revision ID: bb0693433148 | ||
Revises: 38ed909ec074 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.