diff --git a/templates/docker-entrypoint.ejs b/templates/docker-entrypoint.ejs index dad5a5a..61acf91 100755 --- a/templates/docker-entrypoint.ejs +++ b/templates/docker-entrypoint.ejs @@ -56,9 +56,13 @@ if (process.env.DATABASE_URL) { %>'<% if (litefs) { %> && process.env.FLY_REGION === process.env.PRIMARY_REGION<% } %>) { <% if (prisma) { -%> <% if (prismaFile) { -%> -<%= tab(2) %>const source = path.resolve(<% if (nuxtjs) { %>'./.output/server', <% } %>'<%- prismaFile %>') +<%= tab(2) %><%= nuxtjs ? 'let' : 'const' %> source = path.resolve('<%- prismaFile %>') <%= tab(2) %>const target = '/data/' + path.basename(source) <%= tab(2) %>if (!fs.existsSync(source) && fs.existsSync('/data')) fs.symlinkSync(target, source) +<% if (nuxtjs) { -%> +<%= tab(2) %>source = path.resolve('./.output/server', '<%- prismaFile %>') +<%= tab(2) %>if (!fs.existsSync(source) && fs.existsSync('/data')) fs.symlinkSync(target, source) +<% } -%> <% } -%> <% if (prismaFile && prismaSeed && sqlite3) { -%> <%= tab(2) %>const newDb = !fs.existsSync(target) diff --git a/test/frameworks/nuxt-prisma/docker-entrypoint.js b/test/frameworks/nuxt-prisma/docker-entrypoint.js index 67adc88..7ada4fe 100755 --- a/test/frameworks/nuxt-prisma/docker-entrypoint.js +++ b/test/frameworks/nuxt-prisma/docker-entrypoint.js @@ -9,9 +9,11 @@ const env = { ...process.env } ;(async() => { // If running the web server then migrate existing database if (process.argv.slice(2).join(' ') === 'node .output/server/index.mjs') { - const source = path.resolve('./.output/server', './dev.db') + let source = path.resolve('./dev.db') const target = '/data/' + path.basename(source) if (!fs.existsSync(source) && fs.existsSync('/data')) fs.symlinkSync(target, source) + source = path.resolve('./.output/server', './dev.db') + if (!fs.existsSync(source) && fs.existsSync('/data')) fs.symlinkSync(target, source) const newDb = !fs.existsSync(target) await exec('npx prisma migrate deploy') if (newDb) await exec('npx prisma db seed')