Database Layer

This directory contains the database schema and query functions for the House Hunter application.

Files

  • migrations.ts - Contains the database schema definitions and initial data seeding
  • queries.ts - Contains functions for querying the database

Schema

The main table is properties_v1 which stores all property listings with the following fields:

  • id - Unique identifier
  • title - Property title
  • description - Detailed description
  • price - Price in USD
  • bedrooms - Number of bedrooms
  • bathrooms - Number of bathrooms
  • sqft - Square footage
  • address - Street address
  • city - City
  • state - State
  • zip - ZIP code
  • lat - Latitude (for map display)
  • lng - Longitude (for map display)
  • image_url - URL to the property image
  • created_at - Creation timestamp
  • updated_at - Last update timestamp

Usage

The database is automatically initialized when the application starts. The runMigrations function creates the necessary tables and seeds initial data if needed.