add admin for apikey and migration

This commit is contained in:
termie 2013-11-26 17:11:50 -08:00
parent c8284b2bdc
commit bd3585ffcd
3 changed files with 34 additions and 2 deletions

View File

@ -38,8 +38,8 @@ fileConfig(config.config_file_name)
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
# target_metadata = None
from refstack.models import *
target_metadata = Base.metadata
from refstack.models import db
target_metadata = db.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:

View File

@ -0,0 +1,31 @@
"""empty message
Revision ID: 449461dbc725
Revises: 59e15d864941
Create Date: 2013-11-26 16:57:16.062788
"""
# revision identifiers, used by Alembic.
revision = '449461dbc725'
down_revision = '59e15d864941'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table('apikey',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=60), nullable=True),
sa.Column('key', sa.String(length=200), nullable=True),
sa.Column('openid', sa.String(length=200), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('timestamp', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
)
def downgrade():
op.drop_Table('apikey')

View File

@ -22,6 +22,7 @@ def init_app(app):
def configure_admin(app):
admin.add_view(SecureView(models.ApiKey, db.session))
admin.add_view(SecureView(models.Cloud, db.session))
admin.add_view(SecureView(models.User, db.session))
admin.add_view(SecureView(models.Vendor, db.session))