Files
cannaiq/backend/fix-docker-db-urls.ts
2025-11-28 19:45:44 -07:00

73 lines
3.5 KiB
TypeScript

import { Pool } from 'pg';
// Docker database connection
const pool = new Pool({
connectionString: 'postgresql://dutchie:dutchie_local_pass@localhost:54320/dutchie_menus'
});
const updates = [
{ id: 18, url: 'https://dutchie.com/dispensary/curaleaf-dispensary-48th-street' },
{ id: 19, url: 'https://dutchie.com/dispensary/curaleaf-83rd-ave' },
{ id: 20, url: 'https://dutchie.com/dispensary/curaleaf-bell-road' },
{ id: 21, url: 'https://dutchie.com/dispensary/curaleaf-camelback' },
{ id: 22, url: 'https://dutchie.com/dispensary/curaleaf-central' },
{ id: 23, url: 'https://dutchie.com/dispensary/curaleaf-gilbert' },
{ id: 24, url: 'https://dutchie.com/dispensary/curaleaf-glendale-east' },
{ id: 25, url: 'https://dutchie.com/dispensary/curaleaf-glendale-east-kind-relief' },
{ id: 26, url: 'https://dutchie.com/dispensary/curaleaf-glendale' },
{ id: 27, url: 'https://dutchie.com/dispensary/curaleaf-dispensary-midtown' },
{ id: 28, url: 'https://dutchie.com/dispensary/curaleaf-dispensary-peoria' },
{ id: 29, url: 'https://dutchie.com/dispensary/curaleaf-phoenix' },
{ id: 30, url: 'https://dutchie.com/dispensary/curaleaf-queen-creek' },
{ id: 31, url: 'https://dutchie.com/dispensary/curaleaf-queen-creek-whoa' },
{ id: 32, url: 'https://dutchie.com/dispensary/curaleaf-dispensary-scottsdale' },
{ id: 33, url: 'https://dutchie.com/dispensary/curaleaf-dispensary-sedona' },
{ id: 34, url: 'https://dutchie.com/dispensary/curaleaf-tucson' },
{ id: 35, url: 'https://dutchie.com/dispensary/curaleaf-youngtown' },
];
const solFlowerStores = [
{ name: 'Sol Flower - Sun City', slug: 'sol-flower-sun-city', url: 'https://dutchie.com/dispensary/sol-flower-dispensary' },
{ name: 'Sol Flower - South Tucson', slug: 'sol-flower-south-tucson', url: 'https://dutchie.com/dispensary/sol-flower-dispensary-south-tucson' },
{ name: 'Sol Flower - North Tucson', slug: 'sol-flower-north-tucson', url: 'https://dutchie.com/dispensary/sol-flower-dispensary-north-tucson' },
{ name: 'Sol Flower - McClintock (Tempe)', slug: 'sol-flower-mcclintock', url: 'https://dutchie.com/dispensary/sol-flower-dispensary-mcclintock' },
{ name: 'Sol Flower - Deer Valley (Phoenix)', slug: 'sol-flower-deer-valley', url: 'https://dutchie.com/dispensary/sol-flower-dispensary-deer-valley' },
];
async function fixDatabase() {
console.log('🔧 Fixing Docker database...\n');
try {
// Update Curaleaf URLs
console.log('Updating Curaleaf URLs to Dutchie...');
for (const update of updates) {
await pool.query('UPDATE stores SET dutchie_url = $1 WHERE id = $2', [update.url, update.id]);
console.log(`✅ Updated store ID ${update.id}`);
}
// Add Sol Flower stores
console.log('\nAdding Sol Flower stores...');
for (const store of solFlowerStores) {
const result = await pool.query(
`INSERT INTO stores (name, slug, dutchie_url, active, scrape_enabled, logo_url)
VALUES ($1, $2, $3, true, true, $4)
ON CONFLICT (slug) DO UPDATE SET dutchie_url = $3
RETURNING id`,
[store.name, store.slug, store.url, 'https://dutchie.com/favicon.ico']
);
console.log(`✅ Added ${store.name} (ID: ${result.rows[0].id})`);
}
console.log('\n✅ Database fixed! Showing all stores:');
const all = await pool.query('SELECT id, name, dutchie_url FROM stores ORDER BY id');
console.table(all.rows);
} catch (error) {
console.error('❌ Error:', error);
} finally {
await pool.end();
}
}
fixDatabase();