Skip to content
Snippets Groups Projects
Commit 80e57306 authored by michael.minelli's avatar michael.minelli
Browse files

Add Prisma seed file

parent 390180a6
Branches
Tags
No related merge requests found
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
"start:dev" : "npx nodemon src/app.ts", "start:dev" : "npx nodemon src/app.ts",
"start:prod": "NODE_ENV=production npx node --max-http-header-size=1048576 dist/app.js" "start:prod": "NODE_ENV=production npx node --max-http-header-size=1048576 dist/app.js"
}, },
"prisma" : {
"seed": "ts-node prisma/seed.ts"
},
"dependencies" : { "dependencies" : {
"@prisma/client" : "^4.16.2", "@prisma/client" : "^4.16.2",
"axios" : "^1.4.0", "axios" : "^1.4.0",
......
require('dotenv').config(); // ATTENTION : This line MUST be the first of this file
require('../src/shared/helpers/TypeScriptExtensions'); // ATTENTION : This line MUST be the second of this file
import Config from '../src/config/Config';
import logger from '../src/shared/logging/WinstonLogger';
import * as bcrypt from 'bcryptjs';
import db from '../src/helpers/DatabaseHelper';
async function main() {
await db.user.upsert({
where : { gitlabId: 142 },
update: {},
create: {
id : 1,
firstname: 'Michaël',
lastname : 'Minelli',
mail : 'michael@minelli.me',
password : bcrypt.hashSync('123456', Config.userPasswordSaltRounds),
gitlabId : 142,
role : 'colsci',
deleted : false
}
});
}
main().then(async () => {
await db.$disconnect();
}).catch(async (e) => {
logger.error(e);
await db.$disconnect();
process.exit(1);
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment