75 lines
2.5 KiB
Python
75 lines
2.5 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
|
|
"""Add authorization models
|
|
|
|
Revision ID: 011
|
|
Revises: 010
|
|
Create Date: 2014-03-21 17:44:51.248232
|
|
|
|
"""
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '011'
|
|
down_revision = '010'
|
|
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
MYSQL_ENGINE = 'InnoDB'
|
|
MYSQL_CHARSET = 'utf8'
|
|
|
|
|
|
def upgrade(active_plugins=None, options=None):
|
|
|
|
op.create_table(
|
|
'authorizationcodes',
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('code', sa.Unicode(100), nullable=False),
|
|
sa.Column('state', sa.Unicode(100), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('is_active', sa.Boolean(), default=True, server_default="1",
|
|
nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
mysql_engine=MYSQL_ENGINE,
|
|
mysql_charset=MYSQL_CHARSET
|
|
)
|
|
|
|
op.create_table(
|
|
'bearertokens',
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('access_token', sa.Unicode(100), nullable=False),
|
|
sa.Column('refresh_token', sa.Unicode(100), nullable=False),
|
|
sa.Column('expires_in', sa.Integer(), nullable=False),
|
|
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
|
sa.Column('is_active', sa.Boolean(), default=True, server_default="1",
|
|
nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
mysql_engine=MYSQL_ENGINE,
|
|
mysql_charset=MYSQL_CHARSET
|
|
)
|
|
|
|
|
|
def downgrade(active_plugins=None, options=None):
|
|
|
|
op.drop_table('bearertokens')
|
|
op.drop_table('authorizationcodes')
|