Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,210
  • Linux
  • Apple
promptForMigrationName.ts1.37 kB
import { isCi, isInteractive } from '@prisma/internals' import slugify from '@sindresorhus/slugify' import { prompt } from 'prompts' type getMigrationNameOutput = { name?: string userCancelled?: string } export async function getMigrationName(name?: string): Promise<getMigrationNameOutput> { // Truncate if longer const maxMigrationNameLength = 200 if (name) { return { name: slugify(name, { separator: '_' }).substring(0, maxMigrationNameLength), } } // We use prompts.inject() for testing in our CI // If not TTY or CI, use default name else if ((!isInteractive || isCi()) && Boolean(prompt._injected?.length) === false) { return { name: '', } } const messageForPrompt = `Enter a name for the new migration:` // For testing purposes we log the message // An alternative would be to find a way to capture the prompt message from jest tests // (attempted without success) if (Boolean((prompt as any)._injected?.length) === true) { process.stdout.write(messageForPrompt + '\n') } const response = await prompt({ type: 'text', name: 'name', message: messageForPrompt, }) if (!('name' in response)) { return { userCancelled: 'Canceled by user.', } } return { name: slugify(response.name, { separator: '_' }).substring(0, maxMigrationNameLength) || '', } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prisma/prisma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server