Skip to content

Commit

Permalink
fix(nuxt): drizzle seed folder
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Dec 21, 2023
1 parent 8da06f3 commit 7f2ecb7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/playground/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.1
# Version: 0.4.0-beta.0
test:
drizzle:
# Script Commands
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "56ba99a3-1710-4393-95a8-ef0f2e30abd3",
"id": "8f205ab0-1ee7-4e18-9d96-d37dd023c1e2",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "5",
"dialect": "pg",
Expand Down Expand Up @@ -98,4 +98,4 @@
"tables": {},
"columns": {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{
"idx": 0,
"version": "5",
"when": 1703102025134,
"tag": "0000_free_wildside",
"when": 1703166377005,
"tag": "0000_majestic_magma",
"breakpoints": true
}
]
}
}
3 changes: 2 additions & 1 deletion packages/nuxt/playground/pergel/test/drizzle/seeds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function runMigrationsAndSeed() {

if (dbDrop) {
console.warn('Dropping database...')
await db.execute(sql/* SQL */`
await db.execute(sql/* SQL */ `
DROP SCHEMA IF EXISTS drizzle CASCADE;
DROP SCHEMA IF EXISTS public CASCADE;
CREATE SCHEMA public;
Expand All @@ -51,3 +51,4 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA "public";
}

runMigrationsAndSeed()

2 changes: 1 addition & 1 deletion packages/nuxt/playground/pergel/test/drizzle/seeds/seed1.ts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function seed1(db: PostgresJsDatabase) {
},
],
).catch((res) => {
consola.warn('Seeding database... catch', res)
console.warn('Seeding database... catch', res)
})
}).catch((_err: any) => {
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default {
if (!existsSync(resolve(nuxt._pergel._module.moduleDir, 'seeds')))
mkdirSync(resolve(nuxt._pergel._module.moduleDir, 'seeds'), { recursive: true, mode: 0o777 })

if (!existsSync(resolve(nuxt._pergel._module.moduleDir, 'seeds/index.ts'))) {
if (!existsSync(resolve(nuxt._pergel._module.options.seedPaths, 'index.ts'))) {
const readFile = await import(_resolver.resolve('./seed/index.ts')).then(m => m.default).catch(() => null)
if (readFile) {
const file = readFile({
Expand All @@ -75,21 +75,18 @@ export default {
},
migrationDir: `${nuxt._pergel._module.options.migrationsPath}`,
})
writeFileSync(resolve(nuxt._pergel._module.moduleDir, 'seeds/index.ts'), file, {
writeFileSync(resolve(nuxt._pergel._module.options.seedPaths, 'index.ts'), file, {
mode: 0o777,
encoding: 'utf8',
})
}
}

if (!existsSync(resolve(nuxt._pergel._module.moduleDir, 'seeds/seed1.ts'))) {
if (!existsSync(resolve(nuxt._pergel._module.options.seedPaths, 'seeds', 'seed1.ts'))) {
const readFile = await import(_resolver.resolve('./seed/seed1.ts')).then(m => m.default).catch(() => null)
if (readFile) {
const file = readFile()
writeFileSync(resolve(nuxt._pergel._module.moduleDir, 'seeds/seed1.ts'), file, {
mode: 0o777,
encoding: 'utf8',
})
writeFileSync(resolve(nuxt._pergel._module.options.seedPaths, 'seed1.ts'), file)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function seed1(db: PostgresJsDatabase) {
},
],
).catch((res) => {
consola.warn('Seeding database... catch', res)
console.warn('Seeding database... catch', res)
})
}).catch((_err: any) => {
})
Expand Down

0 comments on commit 7f2ecb7

Please sign in to comment.