-
Notifications
You must be signed in to change notification settings - Fork 69
/
schema.prisma
81 lines (67 loc) · 1.65 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
// 省
model Province {
id Int @id @default(autoincrement())
code Int
name String
cities City[]
counties County[]
townes Town[]
villages Village[]
}
// 市
model City {
id Int @id @default(autoincrement())
code Int
name String
counties County[]
townes Town[]
villages Village[]
provinceId Int?
province Province? @relation(fields: [provinceId], references: [id])
}
// 区
model County {
id Int @id @default(autoincrement())
code Int
name String
townes Town[]
villages Village[]
provinceId Int?
province Province? @relation(fields: [provinceId], references: [id])
cityId Int?
city City? @relation(fields: [cityId], references: [id])
}
// 镇
model Town {
id Int @id @default(autoincrement())
code Int
name String
villages Village[]
provinceId Int?
province Province? @relation(fields: [provinceId], references: [id])
cityId Int?
city City? @relation(fields: [cityId], references: [id])
countyId Int?
county County? @relation(fields: [countyId], references: [id])
}
// 街道
model Village {
id Int @id @default(autoincrement())
code Int
name String
provinceId Int?
province Province? @relation(fields: [provinceId], references: [id])
cityId Int?
city City? @relation(fields: [cityId], references: [id])
countyId Int?
county County? @relation(fields: [countyId], references: [id])
townId Int?
town Town? @relation(fields: [townId], references: [id])
}