mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 04:51:11 -05:00
Adds a street_address column to the locations table and updates the LocationSearch component to capture, store, and display full street addresses. This includes database migration, interface updates, and formatter logic.
19 lines
712 B
SQL
19 lines
712 B
SQL
-- Add street_address column to locations table
|
|
ALTER TABLE locations
|
|
ADD COLUMN street_address TEXT;
|
|
|
|
-- Add comment explaining the column
|
|
COMMENT ON COLUMN locations.street_address IS 'Street address including house number and road name (e.g., "375 North Lagoon Drive")';
|
|
|
|
-- Add index for potential searches
|
|
CREATE INDEX idx_locations_street_address ON locations(street_address);
|
|
|
|
-- Update existing records: extract from name if it looks like an address
|
|
-- (This is best-effort cleanup for existing data)
|
|
UPDATE locations
|
|
SET street_address = CASE
|
|
WHEN name ~ '^\d+\s+.*' THEN
|
|
regexp_replace(name, ',.*$', '') -- Extract everything before first comma
|
|
ELSE NULL
|
|
END
|
|
WHERE street_address IS NULL; |