Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhacement rds tables and migrationclean up #134

Merged
merged 6 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions backend/migrations/README
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
To Generate alembic migration during development
To Generate alembic migration during development:

```
export PYTHONPATH=backend
export envname=local
alembic -c backend/alembic.ini revision -m "_release_vX.X.X"
```

To run the upgrade (this is part of the deployment pipeline)
```bash
envname=local alembic revision autogenerate -m"my migration"
alembic -c backend/alembic.ini upgrade head
```

To run migrations locally
```bash
envname=local alembic revision upgrade head
envname=local
alembic revision upgrade head
```
https://alembic.sqlalchemy.org/en/latest/
61 changes: 61 additions & 0 deletions backend/migrations/versions/45a4a4702af1_opensource_v1_2_0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""opensource_v1.2.0

Revision ID: 45a4a4702af1
Revises: ec6ab02aa0cc
Create Date: 2022-09-15 17:53:13.455441

"""
from alembic import op
from sqlalchemy.dialects import postgresql
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '45a4a4702af1'
down_revision = 'bc6ff74a16bc'
branch_labels = None
depends_on = None


def upgrade():
op.drop_column('datapipeline', 'devStages')
op.drop_column('datapipeline', 'inputDatasetUri')
op.drop_column('datapipeline', 'outputDatasetUri')

op.create_table(
'datapipelineenvironments',
sa.Column('label', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('owner', sa.String(), nullable=False),
sa.Column('created', sa.DateTime(), nullable=True),
sa.Column('updated', sa.DateTime(), nullable=True),
sa.Column('deleted', sa.DateTime(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('tags', postgresql.ARRAY(sa.String()), nullable=True),
sa.Column('envPipelineUri', sa.String(), nullable=False),
sa.Column('environmentUri', sa.String(), nullable=False),
sa.Column('environmentLabel', sa.String(), nullable=False),
sa.Column('pipelineUri', sa.String(), nullable=False),
sa.Column('pipelineLabel', sa.String(), nullable=False),
sa.Column('stage', sa.String(), nullable=False),
sa.Column('order', sa.Integer, nullable=False),
sa.Column('region', sa.String(), nullable=False),
sa.Column('AwsAccountId', sa.String(), nullable=False),
sa.Column('samlGroupName', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('envPipelineUri'),
)
pass


def downgrade():
op.add_column(
'datapipeline', sa.Column('inputDatasetUri', sa.String(), nullable=True)
)
op.add_column(
'datapipeline', sa.Column('outputDatasetUri', sa.String(), nullable=True)
)
op.add_column(
'datapipeline', sa.Column('devStages', postgresql.ARRAY(sa.String()), nullable=True)
)
op.drop_table('datapipelineenvironments')
pass
Loading