-
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.
- Loading branch information
1 parent
08050e8
commit 5fccca4
Showing
5 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""initialize database | ||
Revision ID: 74a83030b18d | ||
Revises: | ||
Create Date: 2024-02-23 11:24:57.637919 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '74a83030b18d' | ||
down_revision: Union[str, None] = None | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
def upgrade() -> None: | ||
#Scores table | ||
op.create_table('scores', | ||
Column('id', Integer, primary_key=True), | ||
Column('bibcode',String(19)), | ||
Column('scores', Text), | ||
Column('overrides_id', Integer), | ||
Column('models_id', Integer), | ||
Column('created', UTCDateTime, default=get_date()), | ||
) | ||
op.create_foreign_key('fk_overrides_id_scores', | ||
'scores', | ||
'overrides', | ||
['overrides_id'], | ||
['id']) | ||
op.create_foreign_key('fk_models_id_scores', | ||
'scores', | ||
'models', | ||
['models_id'], | ||
['id']) | ||
|
||
# Overrides table | ||
op.create_table('overrides', | ||
Column('id',Integer, primary_key=True), | ||
Column('override', ARRAY(String)), | ||
Column('created', UTCDateTime, default=get_date()), | ||
) | ||
|
||
# Final Collection table | ||
op.create_table('final_collection', | ||
Column('id', Integer, primary_key=True), | ||
Column('score_id', Integer), | ||
Column('collection', ARRAY(String)), | ||
Column('created', UTCDateTime, default=get_date()), | ||
) | ||
op.create_foreign_key('fk_score_id_final_collection', | ||
'final_collection', | ||
'scores', | ||
['score_id'], | ||
['id']) | ||
|
||
# Models table | ||
op.create_table('models', | ||
Column('id', Integer, primary_key=True), | ||
Column('model', Text), | ||
Column('created', UTCDateTime, default=get_date()), | ||
) | ||
|
||
def downgrade() -> None: | ||
op.drop_constraint('fk_score_id_overrides', 'overrides', type_='foreignkey') | ||
op.drop_constraint('fk_score_id_final_collection', 'final_collection', type_='foreignkey') | ||
op.drop_table('scores') | ||
op.drop_table('overrides') | ||
op.drop_table('final_collection') | ||
|
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