feat: convert all uuid fields from str to proper UUID

ugh had to rewrite alembic migrations instead of just adding a new
one..  will be good to be past this hiccup
This commit is contained in:
Lance Edgar 2024-12-07 23:48:16 -06:00
parent bec16f4de2
commit 6baca8c6b1
2 changed files with 11 additions and 10 deletions

View file

@ -27,7 +27,7 @@ classifiers = [
requires-python = ">= 3.8"
dependencies = [
"SQLAlchemy-Continuum",
"WuttJamaican[db]",
"WuttJamaican[db]>=0.17.0",
]

View file

@ -9,6 +9,7 @@ from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import wuttjamaican.db.util
# revision identifiers, used by Alembic.
@ -25,7 +26,7 @@ def upgrade() -> None:
sa.Column('issued_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('remote_addr', sa.String(length=50), nullable=True),
sa.Column('user_id', sa.String(length=32), nullable=True),
sa.Column('user_id', wuttjamaican.db.util.UUID(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.uuid'], name=op.f('fk_transaction_user_id_user')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_transaction'))
)
@ -33,7 +34,7 @@ def upgrade() -> None:
# person
op.create_table('person_version',
sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False),
sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False),
sa.Column('full_name', sa.String(length=100), autoincrement=False, nullable=True),
sa.Column('first_name', sa.String(length=50), autoincrement=False, nullable=True),
sa.Column('middle_name', sa.String(length=50), autoincrement=False, nullable=True),
@ -49,10 +50,10 @@ def upgrade() -> None:
# user
op.create_table('user_version',
sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False),
sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False),
sa.Column('username', sa.String(length=25), autoincrement=False, nullable=True),
sa.Column('password', sa.String(length=60), autoincrement=False, nullable=True),
sa.Column('person_uuid', sa.String(length=32), autoincrement=False, nullable=True),
sa.Column('person_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True),
sa.Column('active', sa.Boolean(), autoincrement=False, nullable=True),
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
@ -65,7 +66,7 @@ def upgrade() -> None:
# role
op.create_table('role_version',
sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False),
sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False),
sa.Column('name', sa.String(length=100), autoincrement=False, nullable=True),
sa.Column('notes', sa.Text(), autoincrement=False, nullable=True),
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
@ -79,9 +80,9 @@ def upgrade() -> None:
# user_x_role
op.create_table('user_x_role_version',
sa.Column('uuid', sa.String(length=32), autoincrement=False, nullable=False),
sa.Column('user_uuid', sa.String(length=32), autoincrement=False, nullable=True),
sa.Column('role_uuid', sa.String(length=32), autoincrement=False, nullable=True),
sa.Column('uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False),
sa.Column('user_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True),
sa.Column('role_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=True),
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
sa.Column('operation_type', sa.SmallInteger(), nullable=False),
@ -93,7 +94,7 @@ def upgrade() -> None:
# permission
op.create_table('permission_version',
sa.Column('role_uuid', sa.String(length=32), autoincrement=False, nullable=False),
sa.Column('role_uuid', wuttjamaican.db.util.UUID(), autoincrement=False, nullable=False),
sa.Column('permission', sa.String(length=254), autoincrement=False, nullable=False),
sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),