#!/usr/bin/env tsx
import { Pool } from 'pg';
const pool = new Pool({
host: process.env.DB_HOST ?? 'localhost',
port: parseInt(process.env.DB_PORT ?? '5432', 10),
database: process.env.DB_NAME ?? 'exploreit',
user: process.env.DB_USER ?? 'exploreit',
password: process.env.DB_PASSWORD ?? 'exploreit',
});
interface Location {
name: string;
description: string;
latitude: number;
longitude: number;
category: string;
wikipedia_url: string;
}
const ghentLocations: Location[] = [
// Landmarks
{
name: 'Belfry of Ghent',
description: 'Medieval bell tower and one of three medieval towers in the old city centre of Ghent. It stands 91 meters tall and is a UNESCO World Heritage site.',
latitude: 51.0536,
longitude: 3.7256,
category: 'landmark',
wikipedia_url: 'https://en.wikipedia.org/wiki/Belfry_of_Ghent',
},
{
name: 'Gravensteen Castle',
description: 'A medieval castle in Ghent, Belgium. It was built in 1180 by Count Philip of Alsace and served as the seat of the Counts of Flanders until 1353.',
latitude: 51.0573,
longitude: 3.7205,
category: 'landmark',
wikipedia_url: 'https://en.wikipedia.org/wiki/Gravensteen',
},
{
name: 'St. Bavo Cathedral',
description: 'A Gothic cathedral in Ghent containing the famous Ghent Altarpiece by Jan van Eyck. Construction began in 942 and continued through the 16th century.',
latitude: 51.0530,
longitude: 3.7266,
category: 'landmark',
wikipedia_url: 'https://en.wikipedia.org/wiki/St._Bavo_Cathedral',
},
{
name: 'Museum of Fine Arts Ghent',
description: 'Municipal museum with a collection spanning from the Middle Ages to the mid-20th century, including works by Bosch, Rubens, and Van Gogh.',
latitude: 51.0380,
longitude: 3.7247,
category: 'museum',
wikipedia_url: 'https://en.wikipedia.org/wiki/Museum_of_Fine_Arts,_Ghent',
},
{
name: 'Design Museum Gent',
description: 'The only museum in Belgium with an international design collection, housed in an 18th-century mansion with a modern wing by Philippe Samyn.',
latitude: 51.0567,
longitude: 3.7237,
category: 'museum',
wikipedia_url: 'https://en.wikipedia.org/wiki/Design_Museum_Gent',
},
{
name: 'STAM - Ghent City Museum',
description: 'The city museum located in the former Bijloke Abbey, telling the story of Ghent from the Middle Ages to the present day.',
latitude: 51.0442,
longitude: 3.7308,
category: 'museum',
wikipedia_url: 'https://en.wikipedia.org/wiki/STAM_Ghent_City_Museum',
},
{
name: 'Citadel Park',
description: 'A large urban park built on the site of the old citadel, featuring the Museum of Fine Arts, STAM, and the botanical garden.',
latitude: 51.0385,
longitude: 3.7250,
category: 'park',
wikipedia_url: 'https://en.wikipedia.org/wiki/Citadel_Park',
},
{
name: 'Ghent University Botanical Garden',
description: 'A botanical garden housing over 10,000 plant species, featuring tropical greenhouses, a bamboo collection, and an arboretum.',
latitude: 51.0375,
longitude: 3.7280,
category: 'park',
wikipedia_url: 'https://en.wikipedia.org/wiki/Ghent_University_Botanical_Garden',
},
{
name: 'Ghent University',
description: 'One of the largest universities in Belgium, founded in 1817. The main building is a prominent landmark with its Neoclassical architecture.',
latitude: 51.0510,
longitude: 3.7235,
category: 'attraction',
wikipedia_url: 'https://en.wikipedia.org/wiki/Ghent_University',
},
{
name: 'St. Nicholas Church',
description: 'One of the oldest and most prominent landmarks in Ghent, with Gothic architecture dating from the 13th to 15th centuries.',
latitude: 51.0539,
longitude: 3.7235,
category: 'landmark',
wikipedia_url: 'https://en.wikipedia.org/wiki/St._Nicholas_Church,_Ghent',
},
{
name: 'Graslei and Korenlei',
description: 'Historic quays along the Leie river, lined with picturesque medieval guild houses. One of the most photographed spots in Ghent.',
latitude: 51.0545,
longitude: 3.7220,
category: 'attraction',
wikipedia_url: 'https://en.wikipedia.org/wiki/Graslei',
},
{
name: 'SMAK - Municipal Museum of Contemporary Art',
description: 'Museum of contemporary art featuring works from the 1950s onwards, including pieces by Andy Warhol, Joseph Beuys, and Panamarenko.',
latitude: 51.0382,
longitude: 3.7270,
category: 'museum',
wikipedia_url: 'https://en.wikipedia.org/wiki/S.M.A.K.',
},
{
name: 'Vrijdagmarkt',
description: 'A historic square in the heart of Ghent, surrounded by cafes and restaurants. Known for its Friday market tradition since the 12th century.',
latitude: 51.0573,
longitude: 3.7265,
category: 'attraction',
wikipedia_url: 'https://en.wikipedia.org/wiki/Vrijdagmarkt_(Ghent)',
},
{
name: 'Patershol',
description: 'A charming historic neighborhood with narrow cobblestone streets, medieval houses, and a high concentration of restaurants.',
latitude: 51.0575,
longitude: 3.7240,
category: 'attraction',
wikipedia_url: 'https://en.wikipedia.org/wiki/Patershol',
},
{
name: 'St. Peter Abbey',
description: 'A former Benedictine abbey founded in the 7th century, now housing a museum, vineyard, and the Caermers monastery.',
latitude: 51.0535,
longitude: 3.7285,
category: 'landmark',
wikipedia_url: 'https://en.wikipedia.org/wiki/St._Peter_Abbey,_Ghent',
},
// Entertainment
{
name: 'Vooruit Arts Centre',
description: 'A historic arts centre housed in a monumental complex built in 1913, featuring concerts, theatre, dance performances, and cultural events.',
latitude: 51.0475,
longitude: 3.7275,
category: 'entertainment',
wikipedia_url: 'https://en.wikipedia.org/wiki/Vooruit',
},
{
name: 'Kinepolis Ghent',
description: 'A modern multiplex cinema showing the latest international films, located near the city center with multiple screens and premium viewing experiences.',
latitude: 51.0420,
longitude: 3.7320,
category: 'entertainment',
wikipedia_url: 'https://en.wikipedia.org/wiki/Kinepolis',
},
// Other category
{
name: 'Ghent Railway Station',
description: 'The main railway station of Ghent, a beautiful building with Neo-Renaissance architecture, connecting the city to Brussels and other major Belgian cities.',
latitude: 51.0360,
longitude: 3.7110,
category: 'other',
wikipedia_url: 'https://en.wikipedia.org/wiki/Ghent-Sint-Pieters_railway_station',
},
];
async function seedLocations(): Promise<void> {
const client = await pool.connect();
try {
await client.query('BEGIN');
const countResult = await client.query(
'SELECT COUNT(*) as count FROM locations'
);
const count = parseInt(countResult.rows[0].count, 10);
if (count > 0) {
console.log(`Database already contains ${count} locations. Skipping seed.`);
await client.query('ROLLBACK');
return;
}
console.log('Seeding locations database with Ghent attractions...\n');
const insertQuery = `
INSERT INTO locations (
name,
description,
latitude,
longitude,
category,
wikipedia_url
) VALUES ($1, $2, $3, $4, $5::location_category, $6)
RETURNING id, name, category
`;
const inserted: Array<{ id: string; name: string; category: string }> = [];
for (const location of ghentLocations) {
const result = await client.query(insertQuery, [
location.name,
location.description,
location.latitude,
location.longitude,
location.category,
location.wikipedia_url,
]);
inserted.push(result.rows[0]);
console.log(` ā Added: ${location.name} (${location.category})`);
}
await client.query('COMMIT');
console.log(`\nā
Successfully seeded ${inserted.length} locations`);
const verifyResult = await pool.query(
'SELECT category, COUNT(*) as count FROM locations GROUP BY category ORDER BY count DESC'
);
console.log('\nš Locations by category:');
for (const row of verifyResult.rows) {
console.log(` ${row.category}: ${row.count}`);
}
} catch (error) {
await client.query('ROLLBACK');
console.error('ā Error seeding locations:', error);
throw error;
} finally {
client.release();
await pool.end();
}
}
seedLocations().catch((error) => {
console.error('Failed to seed locations:', error);
process.exit(1);
});