Skip to content

Commit 02b28ba

Browse files
committed
comments
* Rename BrainRegionHierarchyName to just BrainRegionHierarchy * for a brain region, its `id` in the original hierarchy.json is now called `annotation_value`: anything w/ `_id` in the name suggests it refers to a table in the DB
1 parent 5fa6b8b commit 02b28ba

23 files changed

+221
-241
lines changed

alembic/versions/20250508_141738_3eba1cc437ec_base_models.py renamed to alembic/versions/20250509_111151_e0ff8e2ab521_base_models.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""base models
22
3-
Revision ID: 3eba1cc437ec
3+
Revision ID: e0ff8e2ab521
44
Revises:
5-
Create Date: 2025-05-08 14:17:38.405723
5+
Create Date: 2025-05-09 11:11:51.270177
66
77
"""
88

@@ -16,7 +16,7 @@
1616
import app.db.types
1717

1818
# revision identifiers, used by Alembic.
19-
revision: str = "3eba1cc437ec"
19+
revision: str = "e0ff8e2ab521"
2020
down_revision: Union[str, None] = None
2121
branch_labels: Union[str, Sequence[str], None] = None
2222
depends_on: Union[str, Sequence[str], None] = None
@@ -172,7 +172,7 @@ def upgrade() -> None:
172172
op.f("ix_annotation_body_legacy_id"), "annotation_body", ["legacy_id"], unique=False
173173
)
174174
op.create_table(
175-
"brain_region_hierarchy_name",
175+
"brain_region_hierarchy",
176176
sa.Column("name", sa.String(), nullable=False),
177177
sa.Column("id", sa.Uuid(), nullable=False),
178178
sa.Column(
@@ -187,19 +187,16 @@ def upgrade() -> None:
187187
server_default=sa.text("now()"),
188188
nullable=False,
189189
),
190-
sa.PrimaryKeyConstraint("id", name=op.f("pk_brain_region_hierarchy_name")),
190+
sa.PrimaryKeyConstraint("id", name=op.f("pk_brain_region_hierarchy")),
191191
)
192192
op.create_index(
193-
op.f("ix_brain_region_hierarchy_name_creation_date"),
194-
"brain_region_hierarchy_name",
193+
op.f("ix_brain_region_hierarchy_creation_date"),
194+
"brain_region_hierarchy",
195195
["creation_date"],
196196
unique=False,
197197
)
198198
op.create_index(
199-
op.f("ix_brain_region_hierarchy_name_name"),
200-
"brain_region_hierarchy_name",
201-
["name"],
202-
unique=True,
199+
op.f("ix_brain_region_hierarchy_name"), "brain_region_hierarchy", ["name"], unique=True
203200
)
204201
op.create_table(
205202
"etype_class",
@@ -351,12 +348,12 @@ def upgrade() -> None:
351348
op.create_index(op.f("ix_species_taxonomy_id"), "species", ["taxonomy_id"], unique=True)
352349
op.create_table(
353350
"brain_region",
354-
sa.Column("hierarchy_id", sa.BigInteger(), nullable=False),
351+
sa.Column("annotation_value", sa.BigInteger(), nullable=False),
355352
sa.Column("name", sa.String(), nullable=False),
356353
sa.Column("acronym", sa.String(), nullable=False),
357354
sa.Column("color_hex_triplet", sa.String(length=6), nullable=False),
358355
sa.Column("parent_structure_id", sa.Uuid(), nullable=True),
359-
sa.Column("hierarchy_name_id", sa.Uuid(), nullable=False),
356+
sa.Column("hierarchy_id", sa.Uuid(), nullable=False),
360357
sa.Column("id", sa.Uuid(), nullable=False),
361358
sa.Column(
362359
"creation_date",
@@ -371,9 +368,9 @@ def upgrade() -> None:
371368
nullable=False,
372369
),
373370
sa.ForeignKeyConstraint(
374-
["hierarchy_name_id"],
375-
["brain_region_hierarchy_name.id"],
376-
name=op.f("fk_brain_region_hierarchy_name_id_brain_region_hierarchy_name"),
371+
["hierarchy_id"],
372+
["brain_region_hierarchy.id"],
373+
name=op.f("fk_brain_region_hierarchy_id_brain_region_hierarchy"),
377374
),
378375
sa.ForeignKeyConstraint(
379376
["parent_structure_id"],
@@ -384,16 +381,13 @@ def upgrade() -> None:
384381
)
385382
op.create_index(op.f("ix_brain_region_acronym"), "brain_region", ["acronym"], unique=False)
386383
op.create_index(
387-
op.f("ix_brain_region_creation_date"), "brain_region", ["creation_date"], unique=False
384+
op.f("ix_brain_region_annotation_value"), "brain_region", ["annotation_value"], unique=False
388385
)
389386
op.create_index(
390-
op.f("ix_brain_region_hierarchy_id"), "brain_region", ["hierarchy_id"], unique=False
387+
op.f("ix_brain_region_creation_date"), "brain_region", ["creation_date"], unique=False
391388
)
392389
op.create_index(
393-
op.f("ix_brain_region_hierarchy_name_id"),
394-
"brain_region",
395-
["hierarchy_name_id"],
396-
unique=False,
390+
op.f("ix_brain_region_hierarchy_id"), "brain_region", ["hierarchy_id"], unique=False
397391
)
398392
op.create_index(op.f("ix_brain_region_name"), "brain_region", ["name"], unique=False)
399393
op.create_index(
@@ -2134,9 +2128,9 @@ def downgrade() -> None:
21342128
op.drop_table("datamaturity_annotation_body")
21352129
op.drop_index(op.f("ix_brain_region_parent_structure_id"), table_name="brain_region")
21362130
op.drop_index(op.f("ix_brain_region_name"), table_name="brain_region")
2137-
op.drop_index(op.f("ix_brain_region_hierarchy_name_id"), table_name="brain_region")
21382131
op.drop_index(op.f("ix_brain_region_hierarchy_id"), table_name="brain_region")
21392132
op.drop_index(op.f("ix_brain_region_creation_date"), table_name="brain_region")
2133+
op.drop_index(op.f("ix_brain_region_annotation_value"), table_name="brain_region")
21402134
op.drop_index(op.f("ix_brain_region_acronym"), table_name="brain_region")
21412135
op.drop_table("brain_region")
21422136
op.drop_index(op.f("ix_species_taxonomy_id"), table_name="species")
@@ -2164,14 +2158,11 @@ def downgrade() -> None:
21642158
op.drop_index(op.f("ix_etype_class_legacy_id"), table_name="etype_class")
21652159
op.drop_index(op.f("ix_etype_class_creation_date"), table_name="etype_class")
21662160
op.drop_table("etype_class")
2161+
op.drop_index(op.f("ix_brain_region_hierarchy_name"), table_name="brain_region_hierarchy")
21672162
op.drop_index(
2168-
op.f("ix_brain_region_hierarchy_name_name"), table_name="brain_region_hierarchy_name"
2169-
)
2170-
op.drop_index(
2171-
op.f("ix_brain_region_hierarchy_name_creation_date"),
2172-
table_name="brain_region_hierarchy_name",
2163+
op.f("ix_brain_region_hierarchy_creation_date"), table_name="brain_region_hierarchy"
21732164
)
2174-
op.drop_table("brain_region_hierarchy_name")
2165+
op.drop_table("brain_region_hierarchy")
21752166
op.drop_index(op.f("ix_annotation_body_legacy_id"), table_name="annotation_body")
21762167
op.drop_index(op.f("ix_annotation_body_creation_date"), table_name="annotation_body")
21772168
op.drop_table("annotation_body")

alembic/versions/20250508_141749_691e6a135156_triggers.py renamed to alembic/versions/20250509_111202_6a639a2e0dac_triggers.py

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""triggers
22
3-
Revision ID: 691e6a135156
4-
Revises: 3eba1cc437ec
5-
Create Date: 2025-05-08 14:17:49.307796
3+
Revision ID: 6a639a2e0dac
4+
Revises: e0ff8e2ab521
5+
Create Date: 2025-05-09 11:12:02.350996
66
77
"""
88

@@ -19,14 +19,41 @@
1919
import app.db.types
2020

2121
# revision identifiers, used by Alembic.
22-
revision: str = "691e6a135156"
23-
down_revision: Union[str, None] = "3eba1cc437ec"
22+
revision: str = "6a639a2e0dac"
23+
down_revision: Union[str, None] = "e0ff8e2ab521"
2424
branch_labels: Union[str, Sequence[str], None] = None
2525
depends_on: Union[str, Sequence[str], None] = None
2626

2727

2828
def upgrade() -> None:
2929
# ### commands auto generated by Alembic - please adjust! ###
30+
public_single_neuron_simulation_single_neuron_simulation_description_vector = PGTrigger(
31+
schema="public",
32+
signature="single_neuron_simulation_description_vector",
33+
on_entity="public.single_neuron_simulation",
34+
is_constraint=False,
35+
definition="BEFORE INSERT OR UPDATE ON single_neuron_simulation\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
36+
)
37+
op.create_entity(public_single_neuron_simulation_single_neuron_simulation_description_vector)
38+
39+
public_subject_subject_description_vector = PGTrigger(
40+
schema="public",
41+
signature="subject_description_vector",
42+
on_entity="public.subject",
43+
is_constraint=False,
44+
definition="BEFORE INSERT OR UPDATE ON subject\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
45+
)
46+
op.create_entity(public_subject_subject_description_vector)
47+
48+
public_reconstruction_morphology_reconstruction_morphology_description_vector = PGTrigger(
49+
schema="public",
50+
signature="reconstruction_morphology_description_vector",
51+
on_entity="public.reconstruction_morphology",
52+
is_constraint=False,
53+
definition="BEFORE INSERT OR UPDATE ON reconstruction_morphology\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
54+
)
55+
op.create_entity(public_reconstruction_morphology_reconstruction_morphology_description_vector)
56+
3057
public_experimental_neuron_density_experimental_neuron_density_description_vector = PGTrigger(
3158
schema="public",
3259
signature="experimental_neuron_density_description_vector",
@@ -47,15 +74,6 @@ def upgrade() -> None:
4774
)
4875
op.create_entity(public_ion_channel_model_ion_channel_model_description_vector)
4976

50-
public_reconstruction_morphology_reconstruction_morphology_description_vector = PGTrigger(
51-
schema="public",
52-
signature="reconstruction_morphology_description_vector",
53-
on_entity="public.reconstruction_morphology",
54-
is_constraint=False,
55-
definition="BEFORE INSERT OR UPDATE ON reconstruction_morphology\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
56-
)
57-
op.create_entity(public_reconstruction_morphology_reconstruction_morphology_description_vector)
58-
5977
public_analysis_software_source_code_analysis_software_source_code_description_vector = PGTrigger(
6078
schema="public",
6179
signature="analysis_software_source_code_description_vector",
@@ -85,6 +103,15 @@ def upgrade() -> None:
85103
)
86104
op.create_entity(public_electrical_cell_recording_electrical_cell_recording_description_vector)
87105

106+
public_single_neuron_synaptome_single_neuron_synaptome_description_vector = PGTrigger(
107+
schema="public",
108+
signature="single_neuron_synaptome_description_vector",
109+
on_entity="public.single_neuron_synaptome",
110+
is_constraint=False,
111+
definition="BEFORE INSERT OR UPDATE ON single_neuron_synaptome\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
112+
)
113+
op.create_entity(public_single_neuron_synaptome_single_neuron_synaptome_description_vector)
114+
88115
public_experimental_bouton_density_experimental_bouton_density_description_vector = PGTrigger(
89116
schema="public",
90117
signature="experimental_bouton_density_description_vector",
@@ -96,15 +123,6 @@ def upgrade() -> None:
96123
public_experimental_bouton_density_experimental_bouton_density_description_vector
97124
)
98125

99-
public_single_neuron_synaptome_single_neuron_synaptome_description_vector = PGTrigger(
100-
schema="public",
101-
signature="single_neuron_synaptome_description_vector",
102-
on_entity="public.single_neuron_synaptome",
103-
is_constraint=False,
104-
definition="BEFORE INSERT OR UPDATE ON single_neuron_synaptome\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
105-
)
106-
op.create_entity(public_single_neuron_synaptome_single_neuron_synaptome_description_vector)
107-
108126
public_mesh_mesh_description_vector = PGTrigger(
109127
schema="public",
110128
signature="mesh_description_vector",
@@ -134,15 +152,6 @@ def upgrade() -> None:
134152
public_single_neuron_synaptome_simulation_single_neuron_synaptome_simulation_description_vector
135153
)
136154

137-
public_subject_subject_description_vector = PGTrigger(
138-
schema="public",
139-
signature="subject_description_vector",
140-
on_entity="public.subject",
141-
is_constraint=False,
142-
definition="BEFORE INSERT OR UPDATE ON subject\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
143-
)
144-
op.create_entity(public_subject_subject_description_vector)
145-
146155
public_experimental_synapses_per_connection_experimental_synapses_per_connection_description_vector = PGTrigger(
147156
schema="public",
148157
signature="experimental_synapses_per_connection_description_vector",
@@ -154,15 +163,6 @@ def upgrade() -> None:
154163
public_experimental_synapses_per_connection_experimental_synapses_per_connection_description_vector
155164
)
156165

157-
public_single_neuron_simulation_single_neuron_simulation_description_vector = PGTrigger(
158-
schema="public",
159-
signature="single_neuron_simulation_description_vector",
160-
on_entity="public.single_neuron_simulation",
161-
is_constraint=False,
162-
definition="BEFORE INSERT OR UPDATE ON single_neuron_simulation\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
163-
)
164-
op.create_entity(public_single_neuron_simulation_single_neuron_simulation_description_vector)
165-
166166
public_unauthorized_private_reference_function_emodel_exemplar_morphology_id_reconstruction_morphology = PGFunction(
167167
schema="public",
168168
signature="unauthorized_private_reference_function_emodel_exemplar_morphology_id_reconstruction_morphology()",
@@ -280,15 +280,6 @@ def downgrade() -> None:
280280
public_unauthorized_private_reference_function_emodel_exemplar_morphology_id_reconstruction_morphology
281281
)
282282

283-
public_single_neuron_simulation_single_neuron_simulation_description_vector = PGTrigger(
284-
schema="public",
285-
signature="single_neuron_simulation_description_vector",
286-
on_entity="public.single_neuron_simulation",
287-
is_constraint=False,
288-
definition="BEFORE INSERT OR UPDATE ON single_neuron_simulation\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
289-
)
290-
op.drop_entity(public_single_neuron_simulation_single_neuron_simulation_description_vector)
291-
292283
public_experimental_synapses_per_connection_experimental_synapses_per_connection_description_vector = PGTrigger(
293284
schema="public",
294285
signature="experimental_synapses_per_connection_description_vector",
@@ -300,15 +291,6 @@ def downgrade() -> None:
300291
public_experimental_synapses_per_connection_experimental_synapses_per_connection_description_vector
301292
)
302293

303-
public_subject_subject_description_vector = PGTrigger(
304-
schema="public",
305-
signature="subject_description_vector",
306-
on_entity="public.subject",
307-
is_constraint=False,
308-
definition="BEFORE INSERT OR UPDATE ON subject\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
309-
)
310-
op.drop_entity(public_subject_subject_description_vector)
311-
312294
public_single_neuron_synaptome_simulation_single_neuron_synaptome_simulation_description_vector = PGTrigger(
313295
schema="public",
314296
signature="single_neuron_synaptome_simulation_description_vector",
@@ -338,15 +320,6 @@ def downgrade() -> None:
338320
)
339321
op.drop_entity(public_mesh_mesh_description_vector)
340322

341-
public_single_neuron_synaptome_single_neuron_synaptome_description_vector = PGTrigger(
342-
schema="public",
343-
signature="single_neuron_synaptome_description_vector",
344-
on_entity="public.single_neuron_synaptome",
345-
is_constraint=False,
346-
definition="BEFORE INSERT OR UPDATE ON single_neuron_synaptome\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
347-
)
348-
op.drop_entity(public_single_neuron_synaptome_single_neuron_synaptome_description_vector)
349-
350323
public_experimental_bouton_density_experimental_bouton_density_description_vector = PGTrigger(
351324
schema="public",
352325
signature="experimental_bouton_density_description_vector",
@@ -358,6 +331,15 @@ def downgrade() -> None:
358331
public_experimental_bouton_density_experimental_bouton_density_description_vector
359332
)
360333

334+
public_single_neuron_synaptome_single_neuron_synaptome_description_vector = PGTrigger(
335+
schema="public",
336+
signature="single_neuron_synaptome_description_vector",
337+
on_entity="public.single_neuron_synaptome",
338+
is_constraint=False,
339+
definition="BEFORE INSERT OR UPDATE ON single_neuron_synaptome\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
340+
)
341+
op.drop_entity(public_single_neuron_synaptome_single_neuron_synaptome_description_vector)
342+
361343
public_electrical_cell_recording_electrical_cell_recording_description_vector = PGTrigger(
362344
schema="public",
363345
signature="electrical_cell_recording_description_vector",
@@ -387,15 +369,6 @@ def downgrade() -> None:
387369
public_analysis_software_source_code_analysis_software_source_code_description_vector
388370
)
389371

390-
public_reconstruction_morphology_reconstruction_morphology_description_vector = PGTrigger(
391-
schema="public",
392-
signature="reconstruction_morphology_description_vector",
393-
on_entity="public.reconstruction_morphology",
394-
is_constraint=False,
395-
definition="BEFORE INSERT OR UPDATE ON reconstruction_morphology\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
396-
)
397-
op.drop_entity(public_reconstruction_morphology_reconstruction_morphology_description_vector)
398-
399372
public_ion_channel_model_ion_channel_model_description_vector = PGTrigger(
400373
schema="public",
401374
signature="ion_channel_model_description_vector",
@@ -416,4 +389,31 @@ def downgrade() -> None:
416389
public_experimental_neuron_density_experimental_neuron_density_description_vector
417390
)
418391

392+
public_reconstruction_morphology_reconstruction_morphology_description_vector = PGTrigger(
393+
schema="public",
394+
signature="reconstruction_morphology_description_vector",
395+
on_entity="public.reconstruction_morphology",
396+
is_constraint=False,
397+
definition="BEFORE INSERT OR UPDATE ON reconstruction_morphology\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
398+
)
399+
op.drop_entity(public_reconstruction_morphology_reconstruction_morphology_description_vector)
400+
401+
public_subject_subject_description_vector = PGTrigger(
402+
schema="public",
403+
signature="subject_description_vector",
404+
on_entity="public.subject",
405+
is_constraint=False,
406+
definition="BEFORE INSERT OR UPDATE ON subject\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
407+
)
408+
op.drop_entity(public_subject_subject_description_vector)
409+
410+
public_single_neuron_simulation_single_neuron_simulation_description_vector = PGTrigger(
411+
schema="public",
412+
signature="single_neuron_simulation_description_vector",
413+
on_entity="public.single_neuron_simulation",
414+
is_constraint=False,
415+
definition="BEFORE INSERT OR UPDATE ON single_neuron_simulation\n FOR EACH ROW EXECUTE FUNCTION\n tsvector_update_trigger(description_vector, 'pg_catalog.english', description, name)",
416+
)
417+
op.drop_entity(public_single_neuron_simulation_single_neuron_simulation_description_vector)
418+
419419
# ### end Alembic commands ###

0 commit comments

Comments
 (0)