-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'os-main' into feat/worksheet-nlq-beta
- Loading branch information
Showing
10 changed files
with
272 additions
and
34 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
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
125 changes: 125 additions & 0 deletions
125
backend/migrations/versions/5a798acc6282_create_version_mf.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,125 @@ | ||
"""create_version_mf | ||
Revision ID: 5a798acc6282 | ||
Revises: 075d344ae2cc | ||
Create Date: 2024-10-10 17:25:09.687099 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import orm | ||
|
||
from dataall.modules.metadata_forms.db.metadata_form_models import ( | ||
MetadataForm, | ||
MetadataFormVersion, | ||
AttachedMetadataForm, | ||
MetadataFormField, | ||
) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5a798acc6282' | ||
down_revision = '075d344ae2cc' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
|
||
op.create_table( | ||
'metadata_form_version', | ||
sa.Column('metadataFormUri', sa.String(), nullable=False), | ||
sa.Column('version', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
['metadataFormUri'], ['metadata_form.uri'], name='f_key_version_metadata', ondelete='CASCADE' | ||
), | ||
sa.PrimaryKeyConstraint('metadataFormUri', 'version'), | ||
) | ||
for mf in session.query(MetadataForm).all(): | ||
version = MetadataFormVersion(metadataFormUri=mf.uri, version=1) | ||
session.add(version) | ||
session.commit() | ||
|
||
op.add_column('attached_metadata_form', sa.Column('version', sa.Integer())) | ||
for amf in session.query(AttachedMetadataForm).all(): | ||
amf.version = 1 | ||
session.commit() | ||
op.alter_column('attached_metadata_form', 'version', nullable=False) | ||
op.drop_constraint('fk_attached_mf_uri', 'attached_metadata_form', type_='foreignkey') | ||
op.create_foreign_key( | ||
'fk_attached_mf_version_uri', | ||
'attached_metadata_form', | ||
'metadata_form_version', | ||
['metadataFormUri', 'version'], | ||
['metadataFormUri', 'version'], | ||
ondelete='CASCADE', | ||
) | ||
|
||
op.add_column('metadata_form_enforcement_rule', sa.Column('version', sa.Integer(), nullable=False)) | ||
op.create_foreign_key( | ||
'f_key_enforcement_version_metadata', | ||
'metadata_form_enforcement_rule', | ||
'metadata_form_version', | ||
['metadataFormUri', 'version'], | ||
['metadataFormUri', 'version'], | ||
ondelete='CASCADE', | ||
) | ||
op.drop_constraint('f_key_enforcement_metadata', 'metadata_form_enforcement_rule', type_='foreignkey') | ||
|
||
op.add_column('metadata_form_field', sa.Column('version', sa.Integer())) | ||
for field in session.query(MetadataFormField).all(): | ||
field.version = 1 | ||
session.commit() | ||
op.alter_column('metadata_form_field', 'version', nullable=False) | ||
op.drop_constraint('fk_mf_filed_form_uri', 'metadata_form_field', type_='foreignkey') | ||
op.create_foreign_key( | ||
'fk_version', | ||
'metadata_form_field', | ||
'metadata_form_version', | ||
['metadataFormUri', 'version'], | ||
['metadataFormUri', 'version'], | ||
ondelete='CASCADE', | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint('fk_version', 'metadata_form_field', type_='foreignkey') | ||
op.drop_column('metadata_form_field', 'version') | ||
op.drop_constraint('f_key_enforcement_version_metadata', 'metadata_form_enforcement_rule', type_='foreignkey') | ||
op.drop_column('metadata_form_enforcement_rule', 'version') | ||
op.drop_constraint('fk_attached_mf_version_uri', 'attached_metadata_form', type_='foreignkey') | ||
op.drop_column('attached_metadata_form', 'version') | ||
op.drop_table('metadata_form_version') | ||
|
||
op.create_foreign_key( | ||
'fk_mf_filed_form_uri', | ||
'metadata_form_field', | ||
'metadata_form', | ||
['metadataFormUri'], | ||
['uri'], | ||
ondelete='CASCADE', | ||
) | ||
|
||
op.create_foreign_key( | ||
'f_key_enforcement_metadata', | ||
'metadata_form_enforcement_rule', | ||
'metadata_form', | ||
['metadataFormUri'], | ||
['uri'], | ||
ondelete='CASCADE', | ||
) | ||
|
||
op.create_foreign_key( | ||
'fk_attached_mf_uri', | ||
'attached_metadata_form', | ||
'metadata_form', | ||
['metadataFormUri'], | ||
['uri'], | ||
ondelete='CASCADE', | ||
) | ||
# ### 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
Oops, something went wrong.