T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.ca/public_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.ca/public_html/scripts/migrate.ts
import { PrismaClient } from '@prisma/client';
import fs from 'fs';
import path from 'path';
import bcrypt from 'bcryptjs';

const prisma = new PrismaClient();

function isValidDate(date: any) {
  return date && !isNaN(new Date(date).getTime());
}

async function migrateData() {
  try {
    // Read JSON files
    const usersData = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'users.json'), 'utf-8'));
    const registrationsData = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'registrations.json'), 'utf-8'));

    console.log('Starting data migration...');

    // Migrate users
    for (const user of usersData) {
      if (!user.email || !user.password) {
        console.warn(`Skipping user with missing email or password: ${JSON.stringify(user)}`);
        continue;
      }
      const createdAt = isValidDate(user.createdAt) ? new Date(user.createdAt) : new Date();
      const updatedAt = isValidDate(user.updatedAt) ? new Date(user.updatedAt) : new Date();
      await prisma.user.create({
        data: {
          id: user.id,
          email: user.email,
          name: user.name || 'Unknown',
          password: user.password, // Note: passwords are already hashed
          role: user.role || 'user',
          createdAt,
          updatedAt
        }
      });
    }
    console.log('Users migrated successfully');

    // Migrate registrations
    for (const registration of registrationsData) {
      if (!registration.id || !registration.name || !registration.email) {
        console.warn(`Skipping registration with missing required fields: ${JSON.stringify(registration)}`);
        continue;
      }
      const createdAt = isValidDate(registration.createdAt) ? new Date(registration.createdAt) : new Date();
      const updatedAt = isValidDate(registration.updatedAt) ? new Date(registration.updatedAt) : new Date();
      await prisma.registration.create({
        data: {
          id: registration.id,
          userId: registration.userId,
          firstName: registration.firstName,
          lastName: registration.lastName,
          email: registration.email,
          phone: registration.phone,
          birthDate: isValidDate(registration.birthDate) ? new Date(registration.birthDate) : new Date('2000-01-01'),
          relationship: registration.relationship,
          message: registration.message,
          address: registration.address,
          detaineeInfo: registration.detaineeInfo,
          preferredLanguage: registration.preferredLanguage || 'en',
          preferredContactMethod: registration.preferredContactMethod || 'email',
          documents: registration.documents,
          status: registration.status || 'pending',
          createdAt,
          updatedAt
        }
      });
    }
    console.log('Registrations migrated successfully');

    console.log('Data migration completed successfully!');
  } catch (error) {
    console.error('Error during migration:', error);
    throw error;
  } finally {
    await prisma.$disconnect();
  }
}

migrateData()
  .catch((error) => {
    console.error('Migration failed:', error);
    process.exit(1);
  }); 

CasperSecurity Mini