110067722: Create the model and dao for services.

This commit creates the data model for services and user_to_service.
The dao is also created to insert, get, activate, and unrestrict the service.
This commit is contained in:
Rebecca Law
2015-12-14 15:59:29 +00:00
parent 6c40e72e78
commit 4b01335703
4 changed files with 156 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
"""empty message
Revision ID: 60_add_service
Revises: 50_alter_verify_code_type
Create Date: 2015-12-14 15:22:55.938819
"""
# revision identifiers, used by Alembic.
revision = '60_add_service'
down_revision = '50_alter_verify_code_type'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('services',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('token_id', sa.BigInteger(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('active', sa.Boolean(), nullable=False),
sa.Column('limit', sa.BigInteger(), nullable=False),
sa.Column('restricted', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_services_token_id'), 'services', ['token_id'], unique=True)
op.create_table('user_to_service',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('service_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
)
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_to_service')
op.drop_index(op.f('ix_services_token_id'), table_name='services')
op.drop_table('services')
### end Alembic commands ###