"""v0.5.1

Revision ID: 9cf68c772527
Revises: 07d58b1c19f2
Create Date: 2026-04-25 12:39:19.976815

"""
from typing import Sequence, Union

import sqlmodel
from alembic import op
import sqlalchemy as sa

import app

# revision identifiers, used by Alembic.
revision: str = '9cf68c772527'
down_revision: Union[str, None] = '07d58b1c19f2'
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('note_share',
    sa.Column('create_time', sa.DateTime(), nullable=False, comment='Created time'),
    sa.Column('update_time', sa.DateTime(), nullable=False, comment='Updated time'),
    sa.Column('id', app.api.models.base.GUID(), nullable=False),
    sa.Column('workspace_id', app.api.models.base.GUID(), nullable=False),
    sa.Column('user_id', app.api.models.base.GUID(), nullable=False),
    sa.Column('note_id', app.api.models.base.GUID(), nullable=False),
    sa.Column('share_id', sqlmodel.sql.sqltypes.AutoString(length=100), nullable=False),
    sa.Column('share_type', sa.String(length=32), nullable=True),
    sa.Column('password', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('expire_time', sa.DateTime(), nullable=True),
    sa.Column('is_active', sa.Integer(), server_default=sa.text('1'), nullable=False),
    sa.Column('view_count', sa.Integer(), server_default=sa.text('0'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('share_id', name='unique_share_id'),
    sa.UniqueConstraint('user_id', 'note_id', name='unique_user_note')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('note_share')
    # ### end Alembic commands ###
