-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create record adjacency list relationship
This adds DB-level support for parent-child record hierarchies, which will facilitate API development relating to HasPart/IsPartOf related identifiers. API tests have been updated to create factory records without parents/children, effectively maintaining the existing API test behaviour. Tests will be reviewed and revised as appropriate with forthcoming record API changes.
- Loading branch information
1 parent
c98fe84
commit fc45d0b
Showing
9 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
migrate/versions/2023_07_19_aa0153edf5a9_create_parent_child_record_relationship.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Create parent-child record relationship | ||
Revision ID: aa0153edf5a9 | ||
Revises: 48bf65c26f62 | ||
Create Date: 2023-07-19 13:58:52.518432 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'aa0153edf5a9' | ||
down_revision = '48bf65c26f62' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - adjusted ### | ||
op.add_column('record', sa.Column('parent_id', sa.String(), nullable=True)) | ||
op.create_foreign_key('record_parent_id_fkey', 'record', 'record', ['parent_id'], ['id'], ondelete='RESTRICT') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - adjusted ### | ||
op.drop_constraint('record_parent_id_fkey', 'record', type_='foreignkey') | ||
op.drop_column('record', 'parent_id') | ||
# ### end Alembic commands ### |
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
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