done
This commit is contained in:
30
apps/backend/prisma/add-column.js
Normal file
30
apps/backend/prisma/add-column.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
await prisma.$executeRawUnsafe('ALTER TABLE `User` ADD COLUMN `viewablePassword` VARCHAR(191) NULL AFTER `passwordHash`;');
|
||||
console.log('✓ Successfully added viewablePassword column to User table');
|
||||
} catch (err) {
|
||||
if (err.message.includes('Duplicate column name')) {
|
||||
console.log('✓ Column viewablePassword already exists');
|
||||
} else {
|
||||
console.error('Error adding column:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Update existing seeded users with their plain passwords
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = 'Ecohub@520' WHERE `username` = 'ecohub';");
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = '123' WHERE `username` = 'ecohubstaff';");
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = '123' WHERE `username` = 'ecouser';");
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = 'SuperAdmin@Secure2026!' WHERE `username` = 'superadmin';");
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = 'Admin@Secure2026!' WHERE `username` = 'admin';");
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = 'UserA@Secure2026!' WHERE `username` = 'usera';");
|
||||
await prisma.$executeRawUnsafe("UPDATE `User` SET `viewablePassword` = 'UserB@Secure2026!' WHERE `username` = 'userb';");
|
||||
|
||||
console.log('✓ Updated existing user viewable passwords');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(console.error)
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user