From 227b6490902c924969b9ba33561a87a1e1ff821f Mon Sep 17 00:00:00 2001 From: Ryan Belgrave Date: Thu, 19 Oct 2017 18:46:54 -0500 Subject: [PATCH] fix tests. Probably should start using prs to test these things --- .../alembic/versions/1fdbfd6b0eea_create_instance.py | 3 ++- .../alembic/versions/52923fe51ede_create_image.py | 2 +- .../alembic/versions/9d6460001e00_create_network.py | 2 +- .../alembic/versions/dadf4ada480a_create_authz.py | 1 + ingredients_db/models/public_key.py | 7 ++++--- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ingredients_db/alembic/versions/1fdbfd6b0eea_create_instance.py b/ingredients_db/alembic/versions/1fdbfd6b0eea_create_instance.py index 3714ef5..4de2dee 100644 --- a/ingredients_db/alembic/versions/1fdbfd6b0eea_create_instance.py +++ b/ingredients_db/alembic/versions/1fdbfd6b0eea_create_instance.py @@ -26,11 +26,12 @@ def upgrade(): sa.Column('name', sa.String, nullable=False), sa.Column('tags', HSTORE), sa.Column('state', sa.Enum(InstanceState), default=InstanceState.BUILDING, nullable=False), + sa.Column('network_port_id', sau.UUIDType, sa.ForeignKey('network_ports.id', ondelete='RESTRICT')), sa.Column('project_id', sau.UUIDType, sa.ForeignKey('projects.id', ondelete='RESTRICT'), nullable=False), sa.Column('current_task_id', sau.UUIDType, sa.ForeignKey('tasks.id')), sa.Column('image_id', sau.UUIDType, sa.ForeignKey('images.id', ondelete='SET NULL')), - sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False), + sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False), diff --git a/ingredients_db/alembic/versions/52923fe51ede_create_image.py b/ingredients_db/alembic/versions/52923fe51ede_create_image.py index 34d5030..db10dbf 100644 --- a/ingredients_db/alembic/versions/52923fe51ede_create_image.py +++ b/ingredients_db/alembic/versions/52923fe51ede_create_image.py @@ -33,7 +33,7 @@ def upgrade(): sa.Column('project_id', sau.UUIDType, sa.ForeignKey('projects.id', ondelete='RESTRICT'), nullable=False), sa.Column('current_task_id', sau.UUIDType, sa.ForeignKey('tasks.id')), - sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False), + sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False), ) diff --git a/ingredients_db/alembic/versions/9d6460001e00_create_network.py b/ingredients_db/alembic/versions/9d6460001e00_create_network.py index 893fc41..9a4a9b0 100644 --- a/ingredients_db/alembic/versions/9d6460001e00_create_network.py +++ b/ingredients_db/alembic/versions/9d6460001e00_create_network.py @@ -33,7 +33,7 @@ def upgrade(): sa.Column('cidr', IPv4Network, nullable=False), sa.Column('pool_start', sau.IPAddressType, nullable=False), sa.Column('pool_end', sau.IPAddressType, nullable=False), - sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False), + sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False), diff --git a/ingredients_db/alembic/versions/dadf4ada480a_create_authz.py b/ingredients_db/alembic/versions/dadf4ada480a_create_authz.py index 2c5000e..34679da 100644 --- a/ingredients_db/alembic/versions/dadf4ada480a_create_authz.py +++ b/ingredients_db/alembic/versions/dadf4ada480a_create_authz.py @@ -70,6 +70,7 @@ def upgrade(): sa.Column('token_id', sau.UUIDType, sa.ForeignKey('authn_tokens.id', ondelete='CASCADE'), nullable=False), sa.Column('role_id', sau.UUIDType, sa.ForeignKey('authz_roles.id', ondelete='CASCADE'), nullable=False), + sa.Column('created_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), nullable=False, index=True), sa.Column('updated_at', sau.ArrowType(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False), ) diff --git a/ingredients_db/models/public_key.py b/ingredients_db/models/public_key.py index b375d1c..f9b28f1 100644 --- a/ingredients_db/models/public_key.py +++ b/ingredients_db/models/public_key.py @@ -1,17 +1,18 @@ -from sqlalchemy import text, Column, String, Text, func +from sqlalchemy import text, Column, String, Text, func, ForeignKey from sqlalchemy_utils import UUIDType, generic_repr, ArrowType from ingredients_db.database import Base -from ingredients_db.models.project import ProjectMixin @generic_repr -class PublicKey(Base, ProjectMixin): +class PublicKey(Base): __tablename__ = 'public_keys' id = Column(UUIDType, server_default=text("uuid_generate_v4()"), primary_key=True) name = Column(String, nullable=False) key = Column(Text, nullable=False) + project_id = Column(UUIDType, ForeignKey('projects.id', ondelete='CASCADE'), nullable=False) + created_at = Column(ArrowType(timezone=True), server_default=func.now(), nullable=False) updated_at = Column(ArrowType(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False)