0.1.2
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@@ -38,6 +39,7 @@ def upgrade() -> None:
|
||||
)
|
||||
with op.batch_alter_table('permissions', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_permissions_id'), ['id'], unique=False)
|
||||
op.execute(text("INSERT INTO permissions (permission) VALUES ('admin');"))
|
||||
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
@@ -76,6 +78,7 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_user_group_user_id_users')),
|
||||
sa.PrimaryKeyConstraint('user_id', 'permission_group_id', name=op.f('pk_user_group'))
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 9b30685906fb
|
||||
Revises: 83b4c2ae88d3
|
||||
Create Date: 2026-07-17 17:40:07.269967
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '9b30685906fb'
|
||||
down_revision: Union[str, Sequence[str], None] = '83b4c2ae88d3'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('refresh_tokens',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('token_hash', sa.String(length=255), nullable=False),
|
||||
sa.Column('device_info', sa.String(length=255), nullable=False),
|
||||
sa.Column('ip_address', sa.String(length=45), nullable=False),
|
||||
sa.Column('is_revoked', sa.Boolean(), nullable=False),
|
||||
sa.Column('expires_at', sa.TIMESTAMP(), nullable=False),
|
||||
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||
sa.Column('replaced_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['replaced_by'], ['refresh_tokens.id'], name=op.f('fk_refresh_tokens_replaced_by_refresh_tokens')),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_refresh_tokens_user_id_users'), ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('pk_refresh_tokens')),
|
||||
sa.UniqueConstraint('token_hash', name=op.f('uq_refresh_tokens_token_hash'))
|
||||
)
|
||||
with op.batch_alter_table('refresh_tokens', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_refresh_tokens_id'), ['id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_refresh_tokens_user_id'), ['user_id'], unique=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('refresh_tokens', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_refresh_tokens_user_id'))
|
||||
batch_op.drop_index(batch_op.f('ix_refresh_tokens_id'))
|
||||
|
||||
op.drop_table('refresh_tokens')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user