prisma-client-php 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/init.js +11 -3
- package/dist/prisma/seed.ts +29 -29
- package/dist/prisma.config.ts +10 -0
- package/package.json +1 -1
package/dist/init.js
CHANGED
|
@@ -72,9 +72,6 @@ function installNpmDependencies(isPrismaPHP) {
|
|
|
72
72
|
if (fs.existsSync(packageJsonPath)) {
|
|
73
73
|
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
|
|
74
74
|
packageJson = JSON.parse(packageJsonContent);
|
|
75
|
-
packageJson.prisma = {
|
|
76
|
-
seed: "tsx prisma/seed.ts",
|
|
77
|
-
};
|
|
78
75
|
if (!isPrismaPHP) {
|
|
79
76
|
packageJson.type = "module";
|
|
80
77
|
}
|
|
@@ -224,6 +221,17 @@ async function main() {
|
|
|
224
221
|
isPrismaPHP
|
|
225
222
|
);
|
|
226
223
|
});
|
|
224
|
+
function copyFileVerbose(src, dest) {
|
|
225
|
+
if (!fs.existsSync(src)) {
|
|
226
|
+
console.warn(`File not found (skip): ${src}`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
fs.copyFileSync(src, dest);
|
|
230
|
+
console.log(`Copied file: ${path.basename(src)}`);
|
|
231
|
+
}
|
|
232
|
+
const prismaConfigSrc = path.join(__dirname, "prisma.config.ts");
|
|
233
|
+
const prismaConfigDest = path.join(process.cwd(), "prisma.config.ts");
|
|
234
|
+
copyFileVerbose(prismaConfigSrc, prismaConfigDest);
|
|
227
235
|
console.log("Finished copying directories.");
|
|
228
236
|
}
|
|
229
237
|
// Run the main function
|
package/dist/prisma/seed.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { PrismaClient } from "@prisma/client";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const prisma = new PrismaClient();
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const userRoleData = [
|
|
6
|
+
{
|
|
7
|
+
id: 1,
|
|
8
|
+
name: "Admin",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 2,
|
|
12
|
+
name: "User",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// ];
|
|
16
|
+
const userData = [
|
|
17
|
+
{
|
|
18
|
+
name: "Juan",
|
|
19
|
+
email: "j@gmail.com",
|
|
20
|
+
password: "$2b$10$mgjotYzIXwrK1MCWmu4tgeUVnLcb.qzvqwxOq4FXEL8k2obwXivDi", // TODO: template password 1234 (bcrypt) testing only
|
|
21
|
+
roleId: 1,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
async function main() {
|
|
26
26
|
// ========================================
|
|
27
27
|
// Code for PostgreSQL
|
|
28
28
|
// ----------------------------------------
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
// await prisma.user.deleteMany();
|
|
64
64
|
// await prisma.user.createMany({ data: userData });
|
|
65
65
|
// ========================================
|
|
66
|
-
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
main()
|
|
69
|
+
.catch((e) => {
|
|
70
|
+
throw e;
|
|
71
|
+
})
|
|
72
|
+
.finally(async () => {
|
|
73
|
+
await prisma.$disconnect();
|
|
74
|
+
});
|
package/package.json
CHANGED