MCPcopy
hub / github.com/prisma/prisma / setupMysql

Function setupMysql

packages/client/src/utils/setupMysql.ts:11–31  ·  view source on GitHub ↗
(options: SetupParams)

Source from the content-addressed store, hash-verified

9}
10
11export async function setupMysql(options: SetupParams): Promise<void> {
12 const { connectionString } = options
13 const { dirname } = options
14 const schema = fs.readFileSync(path.join(dirname, 'setup.sql'), 'utf-8')
15
16 await createDatabase(connectionString).catch((e) => console.error(e))
17
18 const credentials = uriToCredentials(connectionString)
19 const db = await mariadb.createConnection({
20 host: credentials.host,
21 port: credentials.port,
22 database: credentials.database,
23 user: credentials.user,
24 password: credentials.password,
25 multipleStatements: true,
26 allowPublicKeyRetrieval: true,
27 })
28
29 await db.query(schema)
30 await db.end()
31}
32
33export async function tearDownMysql(connectionString: string) {
34 const credentials = uriToCredentials(connectionString)

Callers 1

test.tsFile · 0.90

Calls 6

createDatabaseFunction · 0.90
uriToCredentialsFunction · 0.90
catchMethod · 0.80
errorMethod · 0.80
endMethod · 0.80
queryMethod · 0.45

Tested by

no test coverage detected