## Database Migrations (18 new) - Migrate all primary keys from SERIAL to UUID - Add soft delete (deleted_at) to all 19 entities - Add missing indexes for performance optimization - Add CHECK constraints for data validation - Add user audit fields (last_login_at, timezone, locale) - Add weather station location fields (latitude, longitude, elevation) - Add foreign key relationships (CameraDevice→Device, ValidatedEvent→WeatherStation) - Prepare private key encryption fields ## Backend Entity Updates - All entities updated with UUID primary keys - Added @DeleteDateColumn for soft delete support - Updated relations and foreign key types ## Backend Service/Controller Updates - Changed ID parameters from number to string (UUID) - Removed ParseIntPipe from controllers - Updated TypeORM queries for string IDs ## Frontend Updates - Updated all service interfaces to use string IDs - Fixed CameraDevice.location as JSONB object - Updated weather.ts with new fields (elevation, timezone) - Added Supabase integration hooks and lib - Fixed chart components for new data structure ## Cleanup - Removed deprecated .claude/agents configuration files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import { Client } from 'pg';
|
|
|
|
const SOURCE_DATABASE_URL = 'postgresql://rabbit:g39j90p11@10.85.92.236:5433/dev';
|
|
|
|
async function checkSourceDatabase() {
|
|
const client = new Client({
|
|
connectionString: SOURCE_DATABASE_URL,
|
|
});
|
|
|
|
try {
|
|
console.log('Connecting to source database...');
|
|
await client.connect();
|
|
console.log('Connected successfully!\n');
|
|
|
|
const tables = [
|
|
'user_profiles',
|
|
'user_identities',
|
|
'inventory_devices',
|
|
'devices',
|
|
'device_registrations',
|
|
'device_certificates',
|
|
'device_configurations',
|
|
'device_security_events',
|
|
'camera_devices',
|
|
'raw_events',
|
|
'validated_events',
|
|
'analysis_results',
|
|
'subscription_plans',
|
|
'user_subscriptions',
|
|
'subscription_history',
|
|
'payment_records',
|
|
'weather_stations',
|
|
'weather_observations',
|
|
'weather_forecasts',
|
|
];
|
|
|
|
console.log('Table counts in source database:');
|
|
console.log('================================');
|
|
|
|
let totalRows = 0;
|
|
for (const table of tables) {
|
|
try {
|
|
const result = await client.query(`SELECT count(*) FROM ${table}`);
|
|
const count = parseInt(result.rows[0].count, 10);
|
|
console.log(`${table.padEnd(25)} : ${count}`);
|
|
totalRows += count;
|
|
} catch (error: any) {
|
|
console.log(`${table.padEnd(25)} : ERROR - ${error.message}`);
|
|
}
|
|
}
|
|
|
|
console.log('================================');
|
|
console.log(`Total rows: ${totalRows}`);
|
|
|
|
// Check user_identities details
|
|
console.log('\n\nUser identities with email provider:');
|
|
const emailUsers = await client.query(
|
|
"SELECT email FROM user_identities WHERE provider = 'email'"
|
|
);
|
|
console.log(`Found ${emailUsers.rows.length} email users:`);
|
|
emailUsers.rows.forEach((row) => console.log(` - ${row.email}`));
|
|
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
} finally {
|
|
await client.end();
|
|
}
|
|
}
|
|
|
|
checkSourceDatabase();
|