done
This commit is contained in:
41
apps/backend/prisma/create-user-table.js
Normal file
41
apps/backend/prisma/create-user-table.js
Normal file
@@ -0,0 +1,41 @@
|
||||
require('dotenv').config({ path: __dirname + '/../.env' });
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const ddl = `
|
||||
CREATE TABLE IF NOT EXISTS \`User\` (
|
||||
\`id\` VARCHAR(191) NOT NULL,
|
||||
\`email\` VARCHAR(191) NOT NULL,
|
||||
\`username\` VARCHAR(191) NOT NULL,
|
||||
\`fullName\` VARCHAR(191) NOT NULL,
|
||||
\`companyName\` VARCHAR(191) NOT NULL DEFAULT 'Ecohub',
|
||||
\`allowedCompanies\` TEXT NULL,
|
||||
\`passwordHash\` VARCHAR(191) NOT NULL,
|
||||
\`viewablePassword\` VARCHAR(191) NULL,
|
||||
\`role\` ENUM('SUPER_ADMIN', 'ADMIN', 'USER') NOT NULL DEFAULT 'USER',
|
||||
\`status\` ENUM('ACTIVE', 'SUSPENDED', 'PENDING') NOT NULL DEFAULT 'ACTIVE',
|
||||
\`storageQuotaBytes\` BIGINT NOT NULL DEFAULT 5368709120,
|
||||
\`storageUsedBytes\` BIGINT NOT NULL DEFAULT 0,
|
||||
\`canCreateShareLinks\` BOOLEAN NOT NULL DEFAULT false,
|
||||
\`canDeleteFiles\` BOOLEAN NOT NULL DEFAULT true,
|
||||
\`canViewOtherUsers\` BOOLEAN NOT NULL DEFAULT false,
|
||||
\`remoteFileServerUrl\` VARCHAR(191) NULL,
|
||||
\`canUseRemoteServer\` BOOLEAN NOT NULL DEFAULT true,
|
||||
\`createdAt\` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
\`updatedAt\` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
\`lastLoginAt\` DATETIME(3) NULL,
|
||||
|
||||
UNIQUE INDEX \`User_email_key\`(\`email\`),
|
||||
UNIQUE INDEX \`User_username_key\`(\`username\`),
|
||||
INDEX \`User_role_idx\`(\`role\`),
|
||||
INDEX \`User_status_idx\`(\`status\`),
|
||||
PRIMARY KEY (\`id\`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
`;
|
||||
|
||||
await prisma.$executeRawUnsafe(ddl);
|
||||
console.log('✓ User table created successfully with allowedCompanies!');
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user