Skip to content

Commit

Permalink
Feature/alembic model detection (#205)
Browse files Browse the repository at this point in the history
* time to test showcase

Signed-off-by: Jason Sy <[email protected]>

* revert file changes.. still throwing error? 

Signed-off-by: Jason Sy <[email protected]>

* reverting the right file

Signed-off-by: Jason Sy <[email protected]>

* new alembic revision

Signed-off-by: Jason Sy <[email protected]>

* linter didn't like this

Signed-off-by: Jason Sy <[email protected]>

* existing db column type is varchar

Signed-off-by: Jason Sy <[email protected]>
  • Loading branch information
Jsyro authored Jun 24, 2022
1 parent 160a95b commit 15f0bc3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""autogenerate_sync
Revision ID: e7fdfee68c43
Revises: 2ab74e9499c0
Create Date: 2022-06-23 22:39:44.842386
"""
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "e7fdfee68c43"
down_revision = "2ab74e9499c0"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
# We don't want these to be nullable, but it's going to be re-written soon
op.alter_column(
"tenantwebhook", "tenant_id", existing_type=postgresql.UUID(), nullable=True
)
op.alter_column(
"tenantwebhookmsg", "tenant_id", existing_type=postgresql.UUID(), nullable=True
)

op.create_index(
op.f("ix_verifier_presentation_contact_id"),
"verifier_presentation",
["contact_id"],
unique=False,
)
op.create_index(
op.f("ix_verifier_presentation_tenant_id"),
"verifier_presentation",
["tenant_id"],
unique=False,
)
op.create_foreign_key(
None, "verifier_presentation", "tenant", ["tenant_id"], ["id"]
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "verifier_presentation", type_="foreignkey")
op.drop_index(
op.f("ix_verifier_presentation_tenant_id"), table_name="verifier_presentation"
)
op.drop_index(
op.f("ix_verifier_presentation_contact_id"), table_name="verifier_presentation"
)
op.alter_column(
"tenantwebhookmsg", "tenant_id", existing_type=postgresql.UUID(), nullable=False
)
op.alter_column(
"tenantwebhook", "tenant_id", existing_type=postgresql.UUID(), nullable=False
)
# ### end Alembic commands ###
7 changes: 7 additions & 0 deletions services/traction/api/db/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
from api.db.models.tenant import Tenant # noqa: F401
from api.db.models.tenant_webhook import TenantWebhook # noqa: F401
from api.db.models.tenant_webhook_msg import TenantWebhookMsg # noqa: F401
from api.db.models.tenant_schema import TenantSchema # noqa: F401
from api.db.models.issue_credential import IssueCredential # noqa: F401
from api.db.models.present_credential import PresentCredential # noqa: F401
from api.db.models.tenant_issuer import TenantIssuer # noqa: F401
from api.db.models.tenant_connection import TenantConnection # noqa: F401
from api.db.models.tenant_workflow import TenantWorkflow # noqa: F401

from api.db.models.v1.contact import Contact # noqa: F401
from api.db.models.v1.connection_invitation import ConnectionInvitation # noqa: F401
from api.db.models.v1.governance import SchemaTemplate, CredentialTemplate # noqa: F401
from api.db.models.v1.issuer import IssuerCredential # noqa: F401
from api.db.models.v1.message import Message # noqa: F401
from api.db.models.v1.verifier_presentation import VerifierPresentation # noqa: F401
from api.db.models.v1.tenant_permissions import TenantPermissions # noqa: F401
from api.db.models.v1.tenant_configuration import (
TenantConfiguration,
Expand Down
1 change: 1 addition & 0 deletions services/traction/api/db/models/present_credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PresentCredentialBase(BaseModel):
workflow_id: uuid.UUID = Field(nullable=True, default=None)
pres_exch_id: uuid.UUID = Field(nullable=True, default=None)
presentation: str = Field(nullable=True, default=None)
cred_def_id: str = Field(nullable=True, default=None)


class PresentCredential(PresentCredentialBase, BaseTable, table=True):
Expand Down
4 changes: 2 additions & 2 deletions services/traction/api/db/models/tenant_webhook_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from datetime import datetime
from typing import Optional

from sqlmodel import Field

from api.db.models.base import BaseModel, BaseTable
from sqlmodel import Field


class TenantWebhookMsgBase(BaseModel):
Expand All @@ -23,6 +22,7 @@ class TenantWebhookMsgBase(BaseModel):

class TenantWebhookMsg(TenantWebhookMsgBase, BaseTable, table=True):
# This is the class that represents the table
# may be optional in some modelsomes, but not in the db table
pass


Expand Down

0 comments on commit 15f0bc3

Please sign in to comment.