Initial commit: SIBU 2.0 MISSION
This commit is contained in:
46
backend/alembic/versions/ceda6a5abf0e_add_telemetry_table.py
Normal file
46
backend/alembic/versions/ceda6a5abf0e_add_telemetry_table.py
Normal file
@ -0,0 +1,46 @@
|
||||
"""add telemetry table
|
||||
|
||||
Revision ID: ceda6a5abf0e
|
||||
Revises: c88628a640b6
|
||||
Create Date: 2026-01-27 20:51:06.463716
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'ceda6a5abf0e'
|
||||
down_revision: Union[str, None] = 'c88628a640b6'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('telemetry',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('latitude', sa.Float(), nullable=False),
|
||||
sa.Column('longitude', sa.Float(), nullable=False),
|
||||
sa.Column('speed', sa.Float(), nullable=True),
|
||||
sa.Column('heading', sa.Float(), nullable=True),
|
||||
sa.Column('status', sa.Enum('ACTIVE', 'OFFLINE', 'BREAK', name='vehiclestatus'), nullable=False),
|
||||
sa.Column('timestamp', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_telemetry_timestamp'), 'telemetry', ['timestamp'], unique=False)
|
||||
op.create_index(op.f('ix_telemetry_user_id'), 'telemetry', ['user_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_telemetry_user_id'), table_name='telemetry')
|
||||
op.drop_index(op.f('ix_telemetry_timestamp'), table_name='telemetry')
|
||||
op.drop_table('telemetry')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
Reference in New Issue
Block a user