99 lines
4.5 KiB
Python
99 lines
4.5 KiB
Python
"""initial migration
|
|
|
|
Revision ID: 6cd12cae8c96
|
|
Revises:
|
|
Create Date: 2026-02-06 22:11:10.583387
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '6cd12cae8c96'
|
|
down_revision: Union[str, Sequence[str], None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('locations',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('place_id', sa.BigInteger(), nullable=False),
|
|
sa.Column('osm_id', sa.BigInteger(), nullable=False),
|
|
sa.Column('osm_type', sa.String(length=20), nullable=False),
|
|
sa.Column('latitude', sa.Float(), nullable=False),
|
|
sa.Column('longitude', sa.Float(), nullable=False),
|
|
sa.Column('house_number', sa.String(length=20), nullable=True),
|
|
sa.Column('road', sa.String(length=150), nullable=False),
|
|
sa.Column('city', sa.String(length=100), nullable=False),
|
|
sa.Column('county', sa.String(length=100), nullable=False),
|
|
sa.Column('state', sa.String(length=100), nullable=False),
|
|
sa.Column('postcode', sa.String(length=20), nullable=False),
|
|
sa.Column('country', sa.String(length=100), nullable=False),
|
|
sa.Column('country_code', sa.String(length=10), nullable=False),
|
|
sa.Column('display_name', sa.String(length=300), nullable=False),
|
|
sa.Column('bbox_lat_min', sa.Float(), nullable=False),
|
|
sa.Column('bbox_lat_max', sa.Float(), nullable=False),
|
|
sa.Column('bbox_lon_min', sa.Float(), nullable=False),
|
|
sa.Column('bbox_lon_max', sa.Float(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_locations_id'), 'locations', ['id'], unique=False)
|
|
op.create_index(op.f('ix_locations_place_id'), 'locations', ['place_id'], unique=True)
|
|
op.create_table('owners',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('full_name', sa.String(length=150), nullable=False),
|
|
sa.Column('phone_number', sa.String(length=20), nullable=False),
|
|
sa.Column('email', sa.String(length=150), nullable=False),
|
|
sa.Column('occupation', sa.String(length=100), nullable=False),
|
|
sa.Column('annual_income_range', sa.String(length=50), nullable=False),
|
|
sa.Column('willing_to_rent', sa.Boolean(), nullable=False),
|
|
sa.Column('desired_rent_price', sa.Integer(), nullable=True),
|
|
sa.Column('willing_to_sell', sa.Boolean(), nullable=False),
|
|
sa.Column('desired_sell_price', sa.Integer(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('email'),
|
|
sa.UniqueConstraint('phone_number')
|
|
)
|
|
op.create_table('properties',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('property_type', sa.String(length=50), nullable=False),
|
|
sa.Column('built_up_area', sa.Float(), nullable=False),
|
|
sa.Column('bedrooms', sa.Integer(), nullable=False),
|
|
sa.Column('bathrooms', sa.Integer(), nullable=False),
|
|
sa.Column('purchase_date', sa.Date(), nullable=False),
|
|
sa.Column('purchase_price', sa.Float(), nullable=False),
|
|
sa.Column('sale_listing_date', sa.Date(), nullable=True),
|
|
sa.Column('sale_asking_price', sa.Float(), nullable=True),
|
|
sa.Column('last_renovation_date', sa.Date(), nullable=True),
|
|
sa.Column('renovation_description', sa.String(length=255), nullable=True),
|
|
sa.Column('roof_repair_date', sa.Date(), nullable=True),
|
|
sa.Column('roof_condition', sa.String(length=50), nullable=False),
|
|
sa.Column('available_for_rent', sa.Boolean(), nullable=False),
|
|
sa.Column('expected_rent', sa.Float(), nullable=True),
|
|
sa.Column('rental_available_date', sa.Date(), nullable=True),
|
|
sa.Column('owner_id', sa.Integer(), nullable=False),
|
|
sa.Column('location_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['location_id'], ['locations.id'], ondelete='CASCADE'),
|
|
sa.ForeignKeyConstraint(['owner_id'], ['owners.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('location_id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('properties')
|
|
op.drop_table('owners')
|
|
op.drop_index(op.f('ix_locations_place_id'), table_name='locations')
|
|
op.drop_index(op.f('ix_locations_id'), table_name='locations')
|
|
op.drop_table('locations')
|
|
# ### end Alembic commands ###
|