Spaces:
Running
Running
Upload alembic folder
Browse files- alembic/README.md +86 -0
- alembic/env.py +85 -0
- alembic/script.py.mako +28 -0
- alembic/versions/1812610bee04_add_index_to_procedure_date_and_exam_.py +34 -0
- alembic/versions/1bd963acc519_refactor_hierarchy_and_add_global_.py +85 -0
- alembic/versions/2026_03_27_2314-abf6d06ac8fc_update_enums_to_english.py +50 -0
- alembic/versions/2026_03_28_0013-982b5205d104_update_enums_gender.py +29 -0
- alembic/versions/2026_03_29_1538-992f650fe327_fix_complication_enum_values.py +28 -0
- alembic/versions/2026_04_11_1221-21c4645411b5_add_safety_goal.py +32 -0
- alembic/versions/2026_04_11_1444-b38c15ab328c_add_joined_at.py +32 -0
- alembic/versions/2026_04_12_1615-a3f8c9d1e2b4_add_complexity_level_to_procedure_types.py +31 -0
- alembic/versions/2026_04_17_2246-5aacc2449eb9_add_updated_at_to_procedures.py +32 -0
- alembic/versions/2026_04_19_0914-85499b84a542_add_avatar_url_to_user.py +33 -0
- alembic/versions/2026_04_28_1956-7b246fc32980_add_new_complication_values.py +40 -0
- alembic/versions/2026_04_28_1959-77f4493c0c4d_add_description_to_procedure.py +33 -0
alembic/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ⚗️ Guia Alembic + Supabase (DocBoard)
|
| 2 |
+
|
| 3 |
+
### O que é o Alembic?
|
| 4 |
+
O Alembic é uma ferramenta de **Migração de Banco de Dados**.
|
| 5 |
+
Imagine que o seu banco no Supabase é um organismo vivo. Hoje ele tem 6 tabelas. Amanhã, você decide adicionar a coluna `cidade` na tabela `institutions`.
|
| 6 |
+
|
| 7 |
+
**Sem o Alembic:** Você teria que entrar no SQL do Supabase e rodar comandos manuais, correndo o risco de quebrar o sistema ou apagar dados dos médicos.
|
| 8 |
+
**Com o Alembic:** Você altera o código no Python (`models.py`) e o Alembic detecta a mudança e "evolui" o banco de dados automaticamente, mantendo o histórico de todas as versões.
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
## 🛠️ Configuração Inicial
|
| 13 |
+
|
| 14 |
+
### 1. Instalação
|
| 15 |
+
No seu ambiente virtual (`.venv`), instale o Alembic:
|
| 16 |
+
```bash
|
| 17 |
+
pip install alembic
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
### 2. Inicialização
|
| 21 |
+
Dentro da pasta `/backend`, inicialize o sistema de migrações:
|
| 22 |
+
```bash
|
| 23 |
+
alembic init alembic
|
| 24 |
+
```
|
| 25 |
+
Isso criará uma pasta chamada `alembic` e um arquivo `alembic.ini`.
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## 🔗 Conectando ao Supabase
|
| 30 |
+
|
| 31 |
+
### 1. Configurar a URL do Banco
|
| 32 |
+
No arquivo `alembic.ini`, encontre a linha `sqlalchemy.url` e cole a sua URL de conexão do Supabase (use a porta **6543** para melhor estabilidade):
|
| 33 |
+
|
| 34 |
+
```ini
|
| 35 |
+
sqlalchemy.url = postgresql://postgres:[SENHA]@db.euwzxjcatgsyodglianf.supabase.co:6543/postgres
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
### 2. Ligar ao SQLModel
|
| 39 |
+
Abra o arquivo `alembic/env.py`. Precisamos avisar o Alembic onde estão seus modelos de tabela para que ele possa compará-los com o banco real.
|
| 40 |
+
|
| 41 |
+
No topo do arquivo, adicione:
|
| 42 |
+
```python
|
| 43 |
+
from app.models import SQLModel # Importe o metadado do seu arquivo de modelos
|
| 44 |
+
target_metadata = SQLModel.metadata
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## 🔄 O Fluxo de Trabalho (Dia a Dia)
|
| 50 |
+
|
| 51 |
+
Toda vez que você mudar algo no seu `models.py`, siga estes **3 passos**:
|
| 52 |
+
|
| 53 |
+
### Passo 1: Detectar Mudanças (Revision)
|
| 54 |
+
O Alembic vai olhar seu código Python e olhar o Supabase. Ele vai criar um script com a "receita" da mudança.
|
| 55 |
+
```bash
|
| 56 |
+
alembic revision --autogenerate -m "adicionando coluna cidade em instituicao"
|
| 57 |
+
```
|
| 58 |
+
*Isso criará um arquivo na pasta `alembic/versions`.*
|
| 59 |
+
|
| 60 |
+
### Passo 2: Revisar (Opcional)
|
| 61 |
+
Abra o arquivo gerado na pasta `versions` e veja se ele entendeu corretamente o que você quer fazer (ex: `op.add_column`).
|
| 62 |
+
|
| 63 |
+
### Passo 3: Aplicar no Supabase (Upgrade)
|
| 64 |
+
Agora, envie a mudança para o banco de dados oficial:
|
| 65 |
+
```bash
|
| 66 |
+
alembic upgrade head
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## ⚠️ Comandos Importantes
|
| 72 |
+
|
| 73 |
+
| Comando | O que faz |
|
| 74 |
+
| :--- | :--- |
|
| 75 |
+
| `alembic upgrade head` | Atualiza o banco para a versão mais recente. |
|
| 76 |
+
| `alembic downgrade -1` | Desfaz a última mudança (volta uma versão). |
|
| 77 |
+
| `alembic history` | Lista todas as mudanças feitas desde o início do projeto. |
|
| 78 |
+
| `alembic current` | Mostra qual a versão atual do seu banco de dados. |
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
|
| 82 |
+
## 💡 Por que usar no DocBoard?
|
| 83 |
+
|
| 84 |
+
1. **Segurança de Dados:** No hospital, você não pode "apagar o banco e criar de novo" cada vez que mudar o código, ou perderá os registros de cirurgias. O Alembic altera a estrutura **preservando os dados**.
|
| 85 |
+
2. **Trabalho em Equipe:** Se outro desenvolvedor entrar no projeto, ele só precisa dar um `upgrade head` para ter o banco idêntico ao seu.
|
| 86 |
+
3. **Rollback:** Se você fizer uma alteração que bugou o dashboard, você consegue "voltar no tempo" com um único comando.
|
alembic/env.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from logging.config import fileConfig
|
| 2 |
+
|
| 3 |
+
from sqlalchemy import engine_from_config
|
| 4 |
+
from sqlalchemy import pool
|
| 5 |
+
from sqlmodel import SQLModel
|
| 6 |
+
|
| 7 |
+
from alembic import context
|
| 8 |
+
|
| 9 |
+
# Import your models here to register them with SQLModel.metadata
|
| 10 |
+
from app.models import *
|
| 11 |
+
from app.core.config import settings
|
| 12 |
+
|
| 13 |
+
# this is the Alembic Config object, which provides
|
| 14 |
+
# access to the values within the .ini file in use.
|
| 15 |
+
config = context.config
|
| 16 |
+
|
| 17 |
+
# Interpret the config file for Python logging.
|
| 18 |
+
# This line sets up loggers basically.
|
| 19 |
+
if config.config_file_name is not None:
|
| 20 |
+
fileConfig(config.config_file_name)
|
| 21 |
+
|
| 22 |
+
# add your model's MetaData object here
|
| 23 |
+
# for 'autogenerate' support
|
| 24 |
+
target_metadata = SQLModel.metadata
|
| 25 |
+
|
| 26 |
+
# other values from the config, defined by the needs of env.py,
|
| 27 |
+
# can be acquired:
|
| 28 |
+
# my_important_option = config.get_main_option("my_important_option")
|
| 29 |
+
# ... etc.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def run_migrations_offline() -> None:
|
| 33 |
+
"""Run migrations in 'offline' mode.
|
| 34 |
+
|
| 35 |
+
This configures the context with just a URL
|
| 36 |
+
and not an Engine, though an Engine is acceptable
|
| 37 |
+
here as well. By skipping the Engine creation
|
| 38 |
+
we don't even need a DBAPI to be available.
|
| 39 |
+
|
| 40 |
+
Calls to context.execute() here emit the given string to the
|
| 41 |
+
script output.
|
| 42 |
+
|
| 43 |
+
"""
|
| 44 |
+
url = settings.DATABASE_URL
|
| 45 |
+
context.configure(
|
| 46 |
+
url=url,
|
| 47 |
+
target_metadata=target_metadata,
|
| 48 |
+
literal_binds=True,
|
| 49 |
+
dialect_opts={"paramstyle": "named"},
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
with context.begin_transaction():
|
| 53 |
+
context.run_migrations()
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def run_migrations_online() -> None:
|
| 57 |
+
"""Run migrations in 'online' mode.
|
| 58 |
+
|
| 59 |
+
In this scenario we need to create an Engine
|
| 60 |
+
and associate a connection with the context.
|
| 61 |
+
|
| 62 |
+
"""
|
| 63 |
+
# Use the DATABASE_URL from our settings
|
| 64 |
+
configuration = config.get_section(config.config_ini_section)
|
| 65 |
+
configuration["sqlalchemy.url"] = settings.DATABASE_URL
|
| 66 |
+
|
| 67 |
+
connectable = engine_from_config(
|
| 68 |
+
configuration,
|
| 69 |
+
prefix="sqlalchemy.",
|
| 70 |
+
poolclass=pool.NullPool,
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
with connectable.connect() as connection:
|
| 74 |
+
context.configure(
|
| 75 |
+
connection=connection, target_metadata=target_metadata
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
with context.begin_transaction():
|
| 79 |
+
context.run_migrations()
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
if context.is_offline_mode():
|
| 83 |
+
run_migrations_offline()
|
| 84 |
+
else:
|
| 85 |
+
run_migrations_online()
|
alembic/script.py.mako
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""${message}
|
| 2 |
+
|
| 3 |
+
Revision ID: ${up_revision}
|
| 4 |
+
Revises: ${down_revision | comma,n}
|
| 5 |
+
Create Date: ${create_date}
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
${imports if imports else ""}
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = ${repr(up_revision)}
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
${upgrades if upgrades else "pass"}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def downgrade() -> None:
|
| 27 |
+
"""Downgrade schema."""
|
| 28 |
+
${downgrades if downgrades else "pass"}
|
alembic/versions/1812610bee04_add_index_to_procedure_date_and_exam_.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add index to procedure date and exam_number
|
| 2 |
+
|
| 3 |
+
Revision ID: 1812610bee04
|
| 4 |
+
Revises: 1bd963acc519
|
| 5 |
+
Create Date: 2026-03-18 23:11:15.968400
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '1812610bee04'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = '1bd963acc519'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 24 |
+
op.create_index(op.f('ix_procedures_date'), 'procedures', ['date'], unique=False)
|
| 25 |
+
op.create_index(op.f('ix_procedures_exam_number'), 'procedures', ['exam_number'], unique=False)
|
| 26 |
+
# ### end Alembic commands ###
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def downgrade() -> None:
|
| 30 |
+
"""Downgrade schema."""
|
| 31 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 32 |
+
op.drop_index(op.f('ix_procedures_exam_number'), table_name='procedures')
|
| 33 |
+
op.drop_index(op.f('ix_procedures_date'), table_name='procedures')
|
| 34 |
+
# ### end Alembic commands ###
|
alembic/versions/1bd963acc519_refactor_hierarchy_and_add_global_.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Refactor hierarchy and add global catalog pricing
|
| 2 |
+
|
| 3 |
+
Revision ID: 1bd963acc519
|
| 4 |
+
Revises:
|
| 5 |
+
Create Date: 2026-03-18 22:32:34.890346
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
from sqlalchemy.dialects import postgresql
|
| 13 |
+
import sqlmodel
|
| 14 |
+
|
| 15 |
+
# revision identifiers, used by Alembic.
|
| 16 |
+
revision: str = '1bd963acc519'
|
| 17 |
+
down_revision: Union[str, Sequence[str], None] = None
|
| 18 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 19 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def upgrade() -> None:
|
| 23 |
+
"""Upgrade schema."""
|
| 24 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 25 |
+
op.create_table('institutions',
|
| 26 |
+
sa.Column('id', sa.Uuid(), nullable=False),
|
| 27 |
+
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
| 28 |
+
sa.Column('city', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
| 29 |
+
sa.Column('state', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
| 30 |
+
sa.PrimaryKeyConstraint('id')
|
| 31 |
+
)
|
| 32 |
+
op.create_table('teams',
|
| 33 |
+
sa.Column('id', sa.Uuid(), nullable=False),
|
| 34 |
+
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
| 35 |
+
sa.Column('institution_id', sa.Uuid(), nullable=False),
|
| 36 |
+
sa.Column('invite_code', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
| 37 |
+
sa.Column('revenue_goal', sa.Float(), nullable=False),
|
| 38 |
+
sa.Column('procedure_goal', sa.Integer(), nullable=False),
|
| 39 |
+
sa.ForeignKeyConstraint(['institution_id'], ['institutions.id'], ),
|
| 40 |
+
sa.PrimaryKeyConstraint('id')
|
| 41 |
+
)
|
| 42 |
+
op.create_index(op.f('ix_teams_invite_code'), 'teams', ['invite_code'], unique=True)
|
| 43 |
+
op.create_table('memberships',
|
| 44 |
+
sa.Column('user_id', sa.Uuid(), nullable=False),
|
| 45 |
+
sa.Column('team_id', sa.Uuid(), nullable=False),
|
| 46 |
+
sa.Column('role', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
| 47 |
+
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
| 48 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
| 49 |
+
sa.PrimaryKeyConstraint('user_id', 'team_id')
|
| 50 |
+
)
|
| 51 |
+
op.create_table('team_procedure_values',
|
| 52 |
+
sa.Column('team_id', sa.Uuid(), nullable=False),
|
| 53 |
+
sa.Column('procedure_type_id', sa.Integer(), nullable=False),
|
| 54 |
+
sa.Column('custom_value', sa.Numeric(precision=10, scale=2), nullable=False),
|
| 55 |
+
sa.Column('custom_goal', sa.Integer(), nullable=True),
|
| 56 |
+
sa.ForeignKeyConstraint(['procedure_type_id'], ['procedure_types.id'], ),
|
| 57 |
+
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
|
| 58 |
+
sa.PrimaryKeyConstraint('team_id', 'procedure_type_id')
|
| 59 |
+
)
|
| 60 |
+
op.add_column('procedure_types', sa.Column('code', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
|
| 61 |
+
op.create_index(op.f('ix_procedure_types_code'), 'procedure_types', ['code'], unique=True)
|
| 62 |
+
op.drop_column('procedure_types', 'base_value')
|
| 63 |
+
op.drop_column('procedure_types', 'goal_quantity')
|
| 64 |
+
op.drop_column('procedure_types', 'goal_type')
|
| 65 |
+
op.add_column('procedures', sa.Column('team_id', sa.Uuid(), nullable=False))
|
| 66 |
+
op.create_foreign_key(None, 'procedures', 'teams', ['team_id'], ['id'])
|
| 67 |
+
# ### end Alembic commands ###
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def downgrade() -> None:
|
| 71 |
+
"""Downgrade schema."""
|
| 72 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 73 |
+
op.drop_constraint(None, 'procedures', type_='foreignkey')
|
| 74 |
+
op.drop_column('procedures', 'team_id')
|
| 75 |
+
op.add_column('procedure_types', sa.Column('goal_type', postgresql.ENUM('monthly', 'yearly', name='goaltypeenum'), autoincrement=False, nullable=True))
|
| 76 |
+
op.add_column('procedure_types', sa.Column('goal_quantity', sa.INTEGER(), autoincrement=False, nullable=True))
|
| 77 |
+
op.add_column('procedure_types', sa.Column('base_value', sa.NUMERIC(precision=10, scale=2), autoincrement=False, nullable=False))
|
| 78 |
+
op.drop_index(op.f('ix_procedure_types_code'), table_name='procedure_types')
|
| 79 |
+
op.drop_column('procedure_types', 'code')
|
| 80 |
+
op.drop_table('team_procedure_values')
|
| 81 |
+
op.drop_table('memberships')
|
| 82 |
+
op.drop_index(op.f('ix_teams_invite_code'), table_name='teams')
|
| 83 |
+
op.drop_table('teams')
|
| 84 |
+
op.drop_table('institutions')
|
| 85 |
+
# ### end Alembic commands ###
|
alembic/versions/2026_03_27_2314-abf6d06ac8fc_update_enums_to_english.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Update enums to english
|
| 2 |
+
|
| 3 |
+
Revision ID: abf6d06ac8fc
|
| 4 |
+
Revises: 1812610bee04
|
| 5 |
+
Create Date: 2026-03-27 23:14:37.172067
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = 'abf6d06ac8fc'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = '1812610bee04'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
# SQLModel uses the lowercase class name for the enum type by default
|
| 23 |
+
# Update InternmentTypeEnum
|
| 24 |
+
op.execute("ALTER TYPE internmenttypeenum RENAME VALUE 'eletivo' TO 'elective'")
|
| 25 |
+
op.execute("ALTER TYPE internmenttypeenum RENAME VALUE 'internado' TO 'hospitalized'")
|
| 26 |
+
|
| 27 |
+
# Update AccessRouteEnum
|
| 28 |
+
op.execute("ALTER TYPE accessrouteenum RENAME VALUE 'braquial' TO 'brachial'")
|
| 29 |
+
|
| 30 |
+
# Update ComplicationEnum
|
| 31 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'sem_complicacoes' TO 'no complications'")
|
| 32 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'avc' TO 'stroke'")
|
| 33 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'obito' TO 'death'")
|
| 34 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'outras' TO 'others'")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def downgrade() -> None:
|
| 38 |
+
# Revert ComplicationEnum
|
| 39 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'others' TO 'outras'")
|
| 40 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'death' TO 'obito'")
|
| 41 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'stroke' TO 'avc'")
|
| 42 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'no complications' TO 'sem_complicacoes'")
|
| 43 |
+
|
| 44 |
+
# Revert AccessRouteEnum
|
| 45 |
+
op.execute("ALTER TYPE accessrouteenum RENAME VALUE 'brachial' TO 'braquial'")
|
| 46 |
+
|
| 47 |
+
# Revert InternmentTypeEnum
|
| 48 |
+
op.execute("ALTER TYPE internmenttypeenum RENAME VALUE 'hospitalized' TO 'internado'")
|
| 49 |
+
op.execute("ALTER TYPE internmenttypeenum RENAME VALUE 'elective' TO 'eletivo'")
|
| 50 |
+
|
alembic/versions/2026_03_28_0013-982b5205d104_update_enums_gender.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Update enums gender
|
| 2 |
+
|
| 3 |
+
Revision ID: 982b5205d104
|
| 4 |
+
Revises: abf6d06ac8fc
|
| 5 |
+
Create Date: 2026-03-28 00:13:16.638989
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '982b5205d104'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = 'abf6d06ac8fc'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
# SQLModel uses the lowercase class name for the enum type by default
|
| 23 |
+
op.execute("ALTER TYPE genderenum RENAME VALUE 'M' TO 'male'")
|
| 24 |
+
op.execute("ALTER TYPE genderenum RENAME VALUE 'F' TO 'female'")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def downgrade() -> None:
|
| 28 |
+
op.execute("ALTER TYPE genderenum RENAME VALUE 'female' TO 'F'")
|
| 29 |
+
op.execute("ALTER TYPE genderenum RENAME VALUE 'male' TO 'M'")
|
alembic/versions/2026_03_29_1538-992f650fe327_fix_complication_enum_values.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""fix_complication_enum_values
|
| 2 |
+
|
| 3 |
+
Revision ID: 992f650fe327
|
| 4 |
+
Revises: 982b5205d104
|
| 5 |
+
Create Date: 2026-03-29 15:38:42.307350
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '992f650fe327'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = '982b5205d104'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'no complications' TO 'no_complications'")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def downgrade() -> None:
|
| 27 |
+
"""Downgrade schema."""
|
| 28 |
+
op.execute("ALTER TYPE complicationenum RENAME VALUE 'no_complications' TO 'no complications'")
|
alembic/versions/2026_04_11_1221-21c4645411b5_add_safety_goal.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add safety_goal
|
| 2 |
+
|
| 3 |
+
Revision ID: 21c4645411b5
|
| 4 |
+
Revises: 992f650fe327
|
| 5 |
+
Create Date: 2026-04-11 12:21:18.435002
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '21c4645411b5'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = '992f650fe327'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 24 |
+
op.add_column('teams', sa.Column('safety_goal', sa.Float(), server_default='3.0', nullable=False))
|
| 25 |
+
# ### end Alembic commands ###
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def downgrade() -> None:
|
| 29 |
+
"""Downgrade schema."""
|
| 30 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 31 |
+
op.drop_column('teams', 'safety_goal')
|
| 32 |
+
# ### end Alembic commands ###
|
alembic/versions/2026_04_11_1444-b38c15ab328c_add_joined_at.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add joined_at
|
| 2 |
+
|
| 3 |
+
Revision ID: b38c15ab328c
|
| 4 |
+
Revises: 21c4645411b5
|
| 5 |
+
Create Date: 2026-04-11 14:44:35.800105
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = 'b38c15ab328c'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = '21c4645411b5'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 24 |
+
op.add_column('memberships', sa.Column('joined_at', sa.DateTime(), server_default=sa.func.now(), nullable=False))
|
| 25 |
+
# ### end Alembic commands ###
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def downgrade() -> None:
|
| 29 |
+
"""Downgrade schema."""
|
| 30 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 31 |
+
op.drop_column('memberships', 'joined_at')
|
| 32 |
+
# ### end Alembic commands ###
|
alembic/versions/2026_04_12_1615-a3f8c9d1e2b4_add_complexity_level_to_procedure_types.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add complexity_level to procedure_types
|
| 2 |
+
|
| 3 |
+
Revision ID: a3f8c9d1e2b4
|
| 4 |
+
Revises: b38c15ab328c
|
| 5 |
+
Create Date: 2026-04-12 16:15:00.000000
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = 'a3f8c9d1e2b4'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = 'b38c15ab328c'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
op.add_column(
|
| 24 |
+
'procedure_types',
|
| 25 |
+
sa.Column('complexity_level', sa.String(), server_default='alta', nullable=False)
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def downgrade() -> None:
|
| 30 |
+
"""Downgrade schema."""
|
| 31 |
+
op.drop_column('procedure_types', 'complexity_level')
|
alembic/versions/2026_04_17_2246-5aacc2449eb9_add_updated_at_to_procedures.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Add updated_at to procedures
|
| 2 |
+
|
| 3 |
+
Revision ID: 5aacc2449eb9
|
| 4 |
+
Revises: a3f8c9d1e2b4
|
| 5 |
+
Create Date: 2026-04-17 22:46:36.697882
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '5aacc2449eb9'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = 'a3f8c9d1e2b4'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 24 |
+
op.add_column('procedures', sa.Column('updated_at', sa.DateTime(), nullable=True))
|
| 25 |
+
# ### end Alembic commands ###
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def downgrade() -> None:
|
| 29 |
+
"""Downgrade schema."""
|
| 30 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 31 |
+
op.drop_column('procedures', 'updated_at')
|
| 32 |
+
# ### end Alembic commands ###
|
alembic/versions/2026_04_19_0914-85499b84a542_add_avatar_url_to_user.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add_avatar_url_to_user
|
| 2 |
+
|
| 3 |
+
Revision ID: 85499b84a542
|
| 4 |
+
Revises: 5aacc2449eb9
|
| 5 |
+
Create Date: 2026-04-19 09:14:02.105990
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
import sqlmodel
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# revision identifiers, used by Alembic.
|
| 16 |
+
revision: str = '85499b84a542'
|
| 17 |
+
down_revision: Union[str, Sequence[str], None] = '5aacc2449eb9'
|
| 18 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 19 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def upgrade() -> None:
|
| 23 |
+
"""Upgrade schema."""
|
| 24 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 25 |
+
op.add_column('users', sa.Column('avatar_url', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
| 26 |
+
# ### end Alembic commands ###
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def downgrade() -> None:
|
| 30 |
+
"""Downgrade schema."""
|
| 31 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 32 |
+
op.drop_column('users', 'avatar_url')
|
| 33 |
+
# ### end Alembic commands ###
|
alembic/versions/2026_04_28_1956-7b246fc32980_add_new_complication_values.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add_new_complication_values
|
| 2 |
+
|
| 3 |
+
Revision ID: 7b246fc32980
|
| 4 |
+
Revises: 85499b84a542
|
| 5 |
+
Create Date: 2026-04-28 19:56:44.793682
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '7b246fc32980'
|
| 16 |
+
down_revision: Union[str, Sequence[str], None] = '85499b84a542'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
"""Upgrade schema."""
|
| 23 |
+
# Adicionando novos valores ao tipo ENUM do PostgreSQL
|
| 24 |
+
# Nota: ADD VALUE não pode ser executado dentro de uma transação em algumas versões do PG,
|
| 25 |
+
# mas o Alembic costuma lidar com isso ou podemos configurar.
|
| 26 |
+
# Como o Supabase/Postgres 12+ permite ADD VALUE, vamos executar um por um.
|
| 27 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'vasovagal'")
|
| 28 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'allergy'")
|
| 29 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'vascular'")
|
| 30 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'hematoma'")
|
| 31 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'retroperitoneal_hematoma'")
|
| 32 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'bleeding'")
|
| 33 |
+
op.execute("ALTER TYPE complicationenum ADD VALUE 'stent_thrombosis'")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def downgrade() -> None:
|
| 37 |
+
"""Downgrade schema."""
|
| 38 |
+
# PostgreSQL não permite remover valores de um ENUM facilmente.
|
| 39 |
+
# Geralmente é necessário recriar o tipo, o que é arriscado.
|
| 40 |
+
pass
|
alembic/versions/2026_04_28_1959-77f4493c0c4d_add_description_to_procedure.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add_description_to_procedure
|
| 2 |
+
|
| 3 |
+
Revision ID: 77f4493c0c4d
|
| 4 |
+
Revises: 7b246fc32980
|
| 5 |
+
Create Date: 2026-04-28 19:59:38.308692
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
import sqlmodel
|
| 11 |
+
from alembic import op
|
| 12 |
+
import sqlalchemy as sa
|
| 13 |
+
from sqlalchemy.dialects import postgresql
|
| 14 |
+
|
| 15 |
+
# revision identifiers, used by Alembic.
|
| 16 |
+
revision: str = '77f4493c0c4d'
|
| 17 |
+
down_revision: Union[str, Sequence[str], None] = '7b246fc32980'
|
| 18 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 19 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def upgrade() -> None:
|
| 23 |
+
"""Upgrade schema."""
|
| 24 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 25 |
+
op.add_column('procedures', sa.Column('description', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=True))
|
| 26 |
+
# ### end Alembic commands ###
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def downgrade() -> None:
|
| 30 |
+
"""Downgrade schema."""
|
| 31 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 32 |
+
op.drop_column('procedures', 'description')
|
| 33 |
+
# ### end Alembic commands ###
|