This guide explains how to populate your Supabase database with realistic Asunción bus lines, stops, and routes.
- A Supabase project with the database schema already created
- Access to the Supabase SQL Editor or
psqlcommand line tool - The schema should be applied first (see
docs/schema.sql)
The seeding process uses the following files in order:
seeds/00_drop_all.sql- Optional: Resets all data (useful for testing)seeds/stops.sql- Inserts ~120 bus stops with coordinatesseeds/lines.sql- Inserts 15 bus lines with colors and descriptionsseeds/routes.sql- Associates stops with lines in orderseeds/polylines.sql- Adds GeoJSON geometries for map visualization
- Go to your Supabase project dashboard
- Navigate to SQL Editor in the left sidebar
- Click New Query
Copy and paste the contents of each seed file into the SQL Editor and run them in order:
-- First, optionally reset existing data:
-- Copy contents of seeds/00_drop_all.sql and run
-- Then insert stops:
-- Copy contents of seeds/stops.sql and run
-- Then insert lines:
-- Copy contents of seeds/lines.sql and run
-- Then insert routes:
-- Copy contents of seeds/routes.sql and run
-- Finally, insert polylines:
-- Copy contents of seeds/polylines.sql and runImportant: Run the files in the exact order shown above to respect foreign key constraints.
If you prefer using the command line:
From your Supabase dashboard:
- Go to Settings → Database
- Copy the Connection string (you'll need your database password)
The connection string looks like:
postgresql://postgres:[YOUR-PASSWORD]@[PROJECT-REF].supabase.co:5432/postgres
Execute each seed file in order:
# Set your database password (replace YOUR-PASSWORD)
export DB_PASSWORD="your_password_here"
# Run each seed file in order
psql $DATABASE_URL -f seeds/00_drop_all.sql
psql $DATABASE_URL -f seeds/stops.sql
psql $DATABASE_URL -f seeds/lines.sql
psql $DATABASE_URL -f seeds/routes.sql
psql $DATABASE_URL -f seeds/polylines.sqlOr run them all at once:
psql $DATABASE_URL -f seeds/00_drop_all.sql \
-f seeds/stops.sql \
-f seeds/lines.sql \
-f seeds/routes.sql \
-f seeds/polylines.sqlIf you have the Supabase CLI installed:
# Link to your project (first time only)
supabase link --project-ref YOUR_PROJECT_REF
# Run seed files
supabase db execute -f seeds/00_drop_all.sql
supabase db execute -f seeds/stops.sql
supabase db execute -f seeds/lines.sql
supabase db execute -f seeds/routes.sql
supabase db execute -f seeds/polylines.sqlAfter seeding, verify the data was inserted correctly:
-- Check stops count (should be ~120)
SELECT COUNT(*) FROM stops;
-- Check lines count (should be 15)
SELECT COUNT(*) FROM lines;
-- Check routes count (should be ~170)
SELECT COUNT(*) FROM routes;
-- Check polylines count (should be 15)
SELECT COUNT(*) FROM line_polylines;
-- View all lines with stop counts
SELECT
l.name,
l.description,
l.color,
COUNT(r.stop_id) as stop_count
FROM lines l
LEFT JOIN routes r ON l.id = r.line_id
GROUP BY l.id, l.name, l.description, l.color
ORDER BY l.id;
-- View major hubs and lines that serve them
SELECT
s.name as stop_name,
COUNT(r.line_id) as line_count,
STRING_AGG(l.name, ', ') as lines
FROM stops s
JOIN routes r ON s.id = r.stop_id
JOIN lines l ON r.line_id = l.id
WHERE s.name IN ('Estación Central', 'Plaza de los Héroes', 'Plaza España', 'Mercado Cuatro')
GROUP BY s.id, s.name
ORDER BY line_count DESC;A JSON reference of all lines and routes is available at:
data/bus_lines.json- Complete catalog of lines, stops, and transfer hubs
To start fresh and remove all seeded data:
-- Run the drop script
\i seeds/00_drop_all.sqlOr execute directly:
DELETE FROM line_polylines;
DELETE FROM routes;
DELETE FROM lines;
DELETE FROM stops;Then re-run the seed files as described above.
If you get foreign key constraint errors, ensure you're running the files in the correct order:
stops.sql(must be first)lines.sql(must be second)routes.sql(depends on stops and lines)polylines.sql(depends on lines)
If you encounter duplicate key errors, run 00_drop_all.sql first to clear existing data.
Verify each step completed successfully by checking the row counts:
- Stops: ~120 rows
- Lines: 15 rows
- Routes: ~170 rows
- Polylines: 15 rows
All coordinates are in decimal degrees (WGS 84 format):
- Latitude range: -25.2637° to -25.2500°
- Longitude range: -57.5800° to -57.5500°
These are realistic coordinates for Asunción, Paraguay.
After seeding your database, you can:
- Query the
v_route_detailsview for complete route information - Use the
v_lines_summaryview for line overviews with polylines - Build a map application using the GeoJSON polylines
- Implement route finding between stops
- Display transfer opportunities at major hubs
For issues with the schema or seeding, refer to:
docs/schema.sql- Database schema definitionsdocs/SCHEMA.md- Schema documentationdocs/SUPABASE_SETUP.md- Supabase setup guide