Skip to content

Commit

Permalink
nuxt needs two symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Dec 24, 2024
1 parent 97fc701 commit f519060
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion templates/docker-entrypoint.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion test/frameworks/nuxt-prisma/docker-entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit f519060

Please sign in to comment.