-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2216] setup staging foreign tables (#3313)
## Summary Fixes #{[2216](#2216)} ### Time to review: __5 mins__ ## Changes proposed Mixin, Staging and Foreign attachment models created Migration file created ## Context for reviewers Run migration. new table should be created in staging schema --------- Co-authored-by: nava-platform-bot <[email protected]>
- Loading branch information
1 parent
e72c729
commit 2fbc3d8
Showing
7 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
api/src/db/migrations/versions/2024_12_19_add_attachment_table_staging_and_foreign.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,76 @@ | ||
"""add_attachment_table_staging_and_foreign | ||
Revision ID: f8058a6c0a66 | ||
Revises: 6a23520d2c3c | ||
Create Date: 2024-12-19 19:27:50.327943 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "f8058a6c0a66" | ||
down_revision = "6a23520d2c3c" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"tsynopsisattachment", | ||
sa.Column("syn_att_id", sa.BigInteger(), nullable=False), | ||
sa.Column("opportunity_id", sa.BigInteger(), nullable=False), | ||
sa.Column("att_revision_number", sa.BigInteger(), nullable=True), | ||
sa.Column("att_type", sa.Text(), nullable=True), | ||
sa.Column("mime_type", sa.Text(), nullable=True), | ||
sa.Column("link_url", sa.Text(), nullable=True), | ||
sa.Column("file_name", sa.Text(), nullable=True), | ||
sa.Column("file_desc", sa.Text(), nullable=True), | ||
sa.Column("file_lob", sa.LargeBinary(), nullable=True), | ||
sa.Column("file_lob_size", sa.BigInteger(), nullable=True), | ||
sa.Column("create_date", sa.TIMESTAMP(timezone=True), nullable=True), | ||
sa.Column("created_date", sa.TIMESTAMP(timezone=True), nullable=True), | ||
sa.Column("last_upd_date", sa.TIMESTAMP(timezone=True), nullable=True), | ||
sa.Column("creator_id", sa.Text(), nullable=True), | ||
sa.Column("last_upd_id", sa.Text(), nullable=True), | ||
sa.Column("syn_att_folder_id", sa.BigInteger(), nullable=True), | ||
sa.Column("is_deleted", sa.Boolean(), nullable=False), | ||
sa.Column("transformed_at", sa.TIMESTAMP(timezone=True), nullable=True), | ||
sa.Column( | ||
"created_at", | ||
sa.TIMESTAMP(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=False, | ||
), | ||
sa.Column( | ||
"updated_at", | ||
sa.TIMESTAMP(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=False, | ||
), | ||
sa.Column("deleted_at", sa.TIMESTAMP(timezone=True), nullable=True), | ||
sa.Column("transformation_notes", sa.Text(), nullable=True), | ||
sa.PrimaryKeyConstraint("syn_att_id", name=op.f("tsynopsisattachment_pkey")), | ||
schema="staging", | ||
) | ||
op.create_index( | ||
op.f("tsynopsisattachment_transformed_at_idx"), | ||
"tsynopsisattachment", | ||
["transformed_at"], | ||
unique=False, | ||
schema="staging", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
op.f("tsynopsisattachment_transformed_at_idx"), | ||
table_name="tsynopsisattachment", | ||
schema="staging", | ||
) | ||
op.drop_table("tsynopsisattachment", schema="staging") | ||
# ### 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# SQLAlchemy models for foreign tables. | ||
# | ||
# The order of the columns must match the remote Oracle database. The names are not required to | ||
# match by oracle_fdw, but we are matching them for maintainability. | ||
# | ||
|
||
from src.db.models.legacy_mixin import synopsis_mixin | ||
|
||
from . import foreignbase | ||
|
||
|
||
class tsynopsisattachment(foreignbase.ForeignBase, synopsis_mixin.TsynopsisAttachmentMixin): | ||
__tablename__ = "tsynopsisattachment" |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from . import forecast, opportunity, staging_base, synopsis, tgroups | ||
from . import attachment, forecast, opportunity, staging_base, synopsis, tgroups | ||
|
||
metadata = staging_base.metadata | ||
|
||
__all__ = ["metadata", "opportunity", "forecast", "synopsis", "tgroups"] | ||
__all__ = ["metadata", "opportunity", "forecast", "synopsis", "tgroups", "attachment"] |
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,6 @@ | ||
from src.db.models.legacy_mixin import synopsis_mixin | ||
from src.db.models.staging.staging_base import StagingBase, StagingParamMixin | ||
|
||
|
||
class TsynopsisAttachment(StagingBase, synopsis_mixin.TsynopsisAttachmentMixin, StagingParamMixin): | ||
__tablename__ = "tsynopsisattachment" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.