generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
643e367
commit 9e0e4c7
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @summary All seed data for dev | ||
*/ | ||
const regions = [ | ||
{ id: 1, name: 'Cariboo' }, | ||
]; | ||
|
||
export default regions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import dotenv from 'dotenv'; | ||
import regions from './data.mjs'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
dotenv.config(); | ||
|
||
// const environment = process.env.NODE_ENV || 'production'; | ||
|
||
/** | ||
* @summary Seeds all the necessary base data in both dev and prod. | ||
* Checks for any changes to existing tables and updates accordingly | ||
*/ | ||
async function seedBase() { | ||
const seedingPromises = []; | ||
|
||
seedingPromises.push( | ||
...regions.map((range) => prisma.salaryRange.upsert({ | ||
where: { id: range.id }, | ||
create: range, | ||
update: range, | ||
})), | ||
); | ||
|
||
await Promise.all(seedingPromises); | ||
} | ||
|
||
(async () => { | ||
try { | ||
await seedBase(); | ||
// if (environment === 'development') { | ||
// await seedUsers(); | ||
// await seedInquiries(); | ||
// } | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error('Error during seeding:', error); | ||
} finally { | ||
await prisma.$disconnect(); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
pwd | ||
# Run migrations | ||
npx prisma db push --schema='prisma/schema.prisma' --skip-generate | ||
# Seed data | ||
npx prisma db seed | ||
# Start the application | ||
npm run dev |