Skip to content

Commit

Permalink
warn if no migrations are found
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Dec 27, 2024
1 parent 65cfa74 commit 58a83c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fly.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ GDF.extend(class extends GDF {
this.flyGitHubPrep()
}

// ensure that there is at least one migration present - sqlite3 file
if (this.prismaSeed && !fs.existsSync(path.join(this._appdir, 'prisma/migrations')) && this.prismaFile && !fs.existsSync(path.join(this._appdir, 'prisma', this.prismaFile)) && fs.existsSync(path.join(this._appdir, 'node_modules'))) {
execSync(`${this.npx} prisma migrate dev --name init`, { stdio: 'inherit' })
// ensure that there is at least one migration present
if (this.prismaSeed && !fs.existsSync(path.join(this._appdir, 'prisma/migrations'))) {
if (this.prismaFile && !fs.existsSync(path.join(this._appdir, 'prisma', this.prismaFile)) && fs.existsSync(path.join(this._appdir, 'node_modules'))) {
execSync(`${this.npx} prisma migrate dev --name init`, { stdio: 'inherit' })
} else {
console.error('No migrations found. Please run `npx prisma migrate dev` to create an initial migration.')
this.setExit(42)
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions gdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export class GDF {
// previous answer to conflict prompt
#answer = ''

// exit code
#exitCode = 0

get variant() {
return this.options.alpine ? 'alpine' : 'slim'
}
Expand Down Expand Up @@ -1024,6 +1027,12 @@ export class GDF {
for (const runner of GDF.runners) {
runner.apply(this)
}

process.exit(this.#exitCode)
}

setExit(code) {
this.#exitCode = code
}

// write template file, prompting when there is a conflict
Expand Down

0 comments on commit 58a83c2

Please sign in to comment.