Fix unique constraints for id column and update API key creation (#1764)
* Update .gitignore to ignore additional files and directories * Add migration to fix column types * Bump version to 0.6.17 in pyproject.toml
This commit is contained in:
parent
23bbaf99c8
commit
4b72a7caa8
2 changed files with 95 additions and 4 deletions
8
poetry.lock
generated
8
poetry.lock
generated
|
|
@ -3178,17 +3178,17 @@ protobuf = ">=4.21.6"
|
|||
|
||||
[[package]]
|
||||
name = "grpcio-health-checking"
|
||||
version = "1.62.1"
|
||||
version = "1.62.2"
|
||||
description = "Standard Health Checking Service for gRPC"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "grpcio-health-checking-1.62.1.tar.gz", hash = "sha256:9e56180a941b1d32a077d7491e0611d0483c396358afd5349bf00152612e4583"},
|
||||
{file = "grpcio_health_checking-1.62.1-py3-none-any.whl", hash = "sha256:9ce761c09fc383e7aa2f7e6c0b0b65d5a1157c1b98d1f5871f7c38aca47d49b9"},
|
||||
{file = "grpcio-health-checking-1.62.2.tar.gz", hash = "sha256:a44d1ea1e1510b5c62265dada04d86621bb1491d75de987713c9c0ea005c10a8"},
|
||||
{file = "grpcio_health_checking-1.62.2-py3-none-any.whl", hash = "sha256:f0d77e02457aa00e98ce12c741dca6df7e34dbcc3859681c4a473dc589288e56"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
grpcio = ">=1.62.1"
|
||||
grpcio = ">=1.62.2"
|
||||
protobuf = ">=4.21.6"
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
"""Fix types
|
||||
|
||||
Revision ID: bc804d8e7a18
|
||||
Revises: bc2f01c40e4a
|
||||
Create Date: 2024-04-22 19:33:02.242116
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'bc804d8e7a18'
|
||||
down_revision: Union[str, None] = 'bc2f01c40e4a'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = Inspector.from_engine(conn) # type: ignore
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
table_names = inspector.get_table_names()
|
||||
if "apikey" in table_names:
|
||||
column_names = [col["name"] for col in inspector.get_columns("apikey")]
|
||||
with op.batch_alter_table('apikey', schema=None) as batch_op:
|
||||
if "created_at" in column_names:
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
type_=sa.DateTime(timezone=True),
|
||||
nullable=True)
|
||||
if "last_used_at" in column_names:
|
||||
batch_op.alter_column('last_used_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
type_=sa.DateTime(timezone=True),
|
||||
existing_nullable=True)
|
||||
|
||||
if "credential" in table_names:
|
||||
column_names = [col["name"] for col in inspector.get_columns("credential")]
|
||||
with op.batch_alter_table('credential', schema=None) as batch_op:
|
||||
if "created_at" in column_names:
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
type_=sa.DateTime(timezone=True),
|
||||
nullable=True)
|
||||
if "updated_at" in column_names:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
type_=sa.DateTime(timezone=True),
|
||||
existing_nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = Inspector.from_engine(conn) # type: ignore
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
table_names = inspector.get_table_names()
|
||||
if "credential" in table_names:
|
||||
column_names = [col["name"] for col in inspector.get_columns("credential")]
|
||||
with op.batch_alter_table('credential', schema=None) as batch_op:
|
||||
if "updated_at" in column_names:
|
||||
batch_op.alter_column('updated_at',
|
||||
existing_type=sa.DateTime(timezone=True),
|
||||
type_=postgresql.TIMESTAMP(),
|
||||
existing_nullable=True)
|
||||
if "created_at" in column_names:
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DateTime(timezone=True),
|
||||
type_=postgresql.TIMESTAMP(),
|
||||
nullable=False)
|
||||
|
||||
if "apikey" in table_names:
|
||||
column_names = [col["name"] for col in inspector.get_columns("apikey")]
|
||||
with op.batch_alter_table('apikey', schema=None) as batch_op:
|
||||
if "last_used_at" in column_names:
|
||||
batch_op.alter_column('last_used_at',
|
||||
existing_type=sa.DateTime(timezone=True),
|
||||
type_=postgresql.TIMESTAMP(),
|
||||
existing_nullable=True)
|
||||
if "created_at" in column_names:
|
||||
batch_op.alter_column('created_at',
|
||||
existing_type=sa.DateTime(timezone=True),
|
||||
type_=postgresql.TIMESTAMP(),
|
||||
nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
Loading…
Add table
Add a link
Reference in a new issue