Skip to content

Commit 4281f39

Browse files
committed
cleanup seed files
1 parent 5071d1d commit 4281f39

File tree

5 files changed

+20
-41
lines changed

5 files changed

+20
-41
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Setup your local env - inside the devcontainer **you should not set** `DATABASE_
1010
```bash
1111
USER_ID="<your uuid>"
1212
USER_EMAIL="<your mail>"
13-
USER_ROLE="ADMIN"
1413
NO_AUTH="true"
1514
```
1615

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,7 @@
11
import { Prisma } from '@prisma/client';
2-
import {
3-
NONE_EXAM_DOCUMENT_ID,
4-
RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
5-
RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
6-
RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID
7-
} from './document-roots';
8-
import { TEST_USER_ID } from './users';
9-
import { Access } from '@prisma/client';
10-
import { CLASS_GROUP_ID, PROJECT_GROUP_ID } from './student-groups';
112

12-
const rootUserPermissions: Prisma.RootUserPermissionCreateManyInput[] = [
13-
{
14-
documentRootId: RW_EXERCISE_LOREM_DOCUMENT_ROOT_ID,
15-
userId: TEST_USER_ID,
16-
access: Access.RO_DocumentRoot
17-
},
18-
{
19-
documentRootId: NONE_EXAM_DOCUMENT_ID,
20-
userId: TEST_USER_ID,
21-
access: Access.None_DocumentRoot
22-
}
23-
];
3+
const rootUserPermissions: Prisma.RootUserPermissionCreateManyInput[] = [];
244

25-
const rootGroupPermissions: Prisma.RootGroupPermissionCreateManyInput[] = [
26-
{
27-
documentRootId: RW_EXERCISE_IMPSUM_DOCUMENT_ROOT_ID,
28-
studentGroupId: CLASS_GROUP_ID,
29-
access: Access.RO_DocumentRoot
30-
},
31-
{
32-
documentRootId: NONE_EXAM_DOCUMENT_ID,
33-
studentGroupId: CLASS_GROUP_ID,
34-
access: Access.RW_DocumentRoot
35-
},
36-
{
37-
documentRootId: RO_VISIBILITY_WRAPPER_DOCUMENT_ROOT_ID,
38-
studentGroupId: PROJECT_GROUP_ID,
39-
access: Access.None_DocumentRoot
40-
}
41-
];
5+
const rootGroupPermissions: Prisma.RootGroupPermissionCreateManyInput[] = [];
426

437
export { rootUserPermissions, rootGroupPermissions };

prisma/seed-files/document-roots.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Access, Prisma } from '@prisma/client';
1+
import { Prisma } from '@prisma/client';
22

33
const documentRoots: Prisma.DocumentRootCreateInput[] = [];
44

prisma/seed-files/student-groups.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { FOO_BAR_ID, TEST_USER_ID } from './users';
21
import { Prisma } from '@prisma/client';
32

43
export const ALL_USERS_GROUP_ID = '8f60f838-940a-4ab3-bb65-405308b0db6c';

prisma/seed.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ async function main() {
9393
}
9494
}
9595
});
96+
if (process.env.USER_ID && process.env.USER_EMAIL && process.env.ADMIN_USER_GROUP_ID) {
97+
await prisma.studentGroup.update({
98+
where: { id: ALL_USERS_GROUP_ID },
99+
data: {
100+
users: {
101+
connectOrCreate: seedUsers
102+
.filter((u) => u.role === 'admin')
103+
.map((user) => ({
104+
where: {
105+
id: { studentGroupId: ALL_USERS_GROUP_ID, userId: user.id! }
106+
},
107+
create: { userId: user.id! }
108+
}))
109+
}
110+
}
111+
});
112+
}
96113
}
97114

98115
main()

0 commit comments

Comments
 (0)