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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
use indoc::indoc;

/// Most basic datamodel containing only a model with ID
/// for the most rudimentary testing.
pub fn generic() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            field String?
        }"
    };

    schema.to_owned()
}

/// User model with some basic fields and unique constraints.
pub fn user() -> String {
    let schema = indoc! {
        "model User {
            #id(id, Int, @id)
            first_name String
            last_name  String
            email      String    @unique
            birthday   DateTime?

            @@unique([first_name, last_name])
        }"
    };

    schema.to_owned()
}

/// Test model containing all possible Prisma scalar types, nullable.
/// Excludes capability-dependent types (e.g. JSON, Decimal).
pub fn common_nullable_types() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            string  String?
            int     Int?
            bInt    BigInt?
            float   Float?
            bytes   Bytes?
            bool    Boolean?
            dt      DateTime?
        }"
    };

    schema.to_owned()
}

/// Test model containing all common Prisma numeric types.
pub fn common_numeric_types() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            int     Int
            bInt    BigInt
            float   Float
        }"
    };

    schema.to_owned()
}

/// Test model containing all common Prisma numeric and string types.
pub fn common_text_and_numeric_types() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            int     Int
            bInt    BigInt
            float   Float
            string  String
        }"
    };

    schema.to_owned()
}

/// Test model containing all common Prisma numeric and string types, optional.
pub fn common_text_and_numeric_types_optional() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            int     Int?
            bInt    BigInt?
            float   Float?
            string  String?
        }"
    };

    schema.to_owned()
}

/// Test model containing all possible Prisma scalar types.
/// Excludes capability-dependent types (e.g. JSON).
pub fn common_types() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            string  String
            int     Int
            bInt    BigInt
            float   Float
            bytes   Bytes
            bool    Boolean
            dt      DateTime
        }"
    };

    schema.to_owned()
}

/// Test model containing all possible Prisma list types.
/// Excludes capability-dependent types (e.g. JSON).
pub fn common_list_types() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id)
            string  String[]
            int     Int[]
            bInt    BigInt[]
            float   Float[]
            bytes   Bytes[]
            bool    Boolean[]
            dt      DateTime[]
        }"
    };

    schema.to_owned()
}

pub fn string_combination_unique() -> String {
    let schema = indoc! {
        r#"model TestModel {
            #id(id, Int, @id)
            fieldA String
            fieldB String
            fieldC String
            fieldD String

            @@unique([fieldA, fieldB, fieldC, fieldD])
          }"#
    };

    schema.to_owned()
}

pub fn string_combination() -> String {
    let schema = indoc! {
        r#"model TestModel {
            #id(id, Int, @id)
            fieldA String
            fieldB String
            fieldC String
            fieldD String
          }"#
    };

    schema.to_owned()
}

pub fn autoinc_id() -> String {
    let schema = indoc! {
        "model TestModel {
            #id(id, Int, @id, @default(autoincrement()))
        }"
    };

    schema.to_owned()
}

pub fn autoinc_id_cockroachdb() -> String {
    let schema = indoc! {
        r#"
        model TestModel {
            #id(id, BigInt, @id, @default(autoincrement()))
        }

        model TestModelSeq {
            #id(id, Int, @id, @default(sequence()))
        }
        "#
    };

    schema.to_owned()
}