Dump changes

This commit is contained in:
Andrey Chervyakov 2021-10-09 21:33:03 +06:00
parent b49c6ced26
commit a4b572dcc7
40 changed files with 186 additions and 37 deletions

Binary file not shown.

View file

@ -9,8 +9,9 @@ from alembic import context
sys.path.append(str(pathlib.Path(__file__).resolve().parents[2]))
from app.db import DATABASE_URL
from app.db import DATABASE_URL, EntityBase
from app.user.model import User
from app.role.model import Role
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
@ -24,7 +25,7 @@ fileConfig(config.config_file_name)
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = [User.metadata]
target_metadata = EntityBase.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:

View file

@ -0,0 +1,39 @@
"""Add roles
Revision ID: 2a84260bc774
Revises: 646ae6f3e17a
Create Date: 2021-02-28 23:06:29.207602
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2a84260bc774'
down_revision = '646ae6f3e17a'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('roles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('creation_date', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.add_column('users', sa.Column('role_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'users', 'roles', ['role_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'users', type_='foreignkey')
op.drop_column('users', 'role_id')
op.drop_table('roles')
# ### end Alembic commands ###