MCPcopy Index your code
hub / github.com/epicweb-dev/epic-stack / getMigrationSqls

Function getMigrationSqls

tests/db-utils.ts:119–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117
118let _migrationSqls: Array<Array<string>> | undefined
119async function getMigrationSqls() {
120 if (_migrationSqls) return _migrationSqls
121
122 const migrationSqls: Array<Array<string>> = []
123 const migrationPaths = (await fs.promises.readdir('prisma/migrations'))
124 .filter((dir) => dir !== 'migration_lock.toml')
125 .map((dir) => `prisma/migrations/${dir}/migration.sql`)
126
127 for (const path of migrationPaths) {
128 const sql = await fs.promises.readFile(path, 'utf8')
129 const statements = sql
130 .split(';')
131 .map((statement) => statement.trim())
132 .filter(Boolean)
133 migrationSqls.push(statements)
134 }
135
136 _migrationSqls = migrationSqls
137
138 return migrationSqls
139}
140
141export async function cleanupDb() {
142 const db = new Database(process.env.DATABASE_URL!.replace('file:', ''))

Callers 1

cleanupDbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected