Add migration for SeaLion

This commit is contained in:
Backend IM Bot 2025-03-25 12:30:55 -05:00
parent 3f06295b16
commit 9b38518d5b

View File

@ -0,0 +1,48 @@
"""create sealions table
Revision ID: 9876543210ab
Revises:
Create Date: 2023-05-23 10:30:00.000000
"""
from alembic import op
import sqlalchemy as sa
import uuid
# revision identifiers, used by Alembic
revision = '9876543210ab'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'sealions',
sa.Column('id', sa.String, primary_key=True, default=lambda: str(uuid.uuid4())),
sa.Column('name', sa.String, nullable=False),
sa.Column('species', sa.String, nullable=False),
sa.Column('age', sa.Integer),
sa.Column('weight', sa.Float),
sa.Column('location', sa.String, index=True),
sa.Column('created_at', sa.DateTime, server_default=sa.func.now()),
sa.Column('updated_at', sa.DateTime, server_default=sa.func.now(), onupdate=sa.func.now())
)
def downgrade():
op.drop_table('sealions')
```
This Alembic migration script creates a table named `sealions` with the following columns:
- `id` (String, primary key, default value generated using `uuid.uuid4()`)
- `name` (String, not nullable)
- `species` (String, not nullable)
- `age` (Integer)
- `weight` (Float)
- `location` (String, indexed)
- `created_at` (DateTime, default value set to current timestamp)
- `updated_at` (DateTime, default value set to current timestamp, updated on each row update)
The `upgrade()` function creates the table, while the `downgrade()` function drops the table.