From 9b38518d5bc915324dfcb1a7a81d852e71989920 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 12:30:55 -0500 Subject: [PATCH] Add migration for SeaLion --- ...20250325_123049_86c19e66_create_sealion.py | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 alembic/versions/20250325_123049_86c19e66_create_sealion.py diff --git a/alembic/versions/20250325_123049_86c19e66_create_sealion.py b/alembic/versions/20250325_123049_86c19e66_create_sealion.py new file mode 100644 index 0000000..82ee332 --- /dev/null +++ b/alembic/versions/20250325_123049_86c19e66_create_sealion.py @@ -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. \ No newline at end of file