Commit 069ef53 1 parent a24e487 commit 069ef53 Copy full SHA for 069ef53
File tree 10 files changed +23
-19
lines changed
migrations/2024-03-12-143107_make_budget_nullable
10 files changed +23
-19
lines changed Original file line number Diff line number Diff line change
1
+ ALTER TABLE study ALTER COLUMN budget SET NOT NULL ;
2
+ ALTER TABLE project ALTER COLUMN budget SET NOT NULL ;
Original file line number Diff line number Diff line change
1
+ ALTER TABLE study ALTER COLUMN budget DROP NOT NULL ;
2
+ ALTER TABLE project ALTER COLUMN budget DROP NOT NULL ;
Original file line number Diff line number Diff line change @@ -4475,6 +4475,7 @@ components:
4475
4475
properties :
4476
4476
budget :
4477
4477
format : int32
4478
+ nullable : true
4478
4479
type : integer
4479
4480
creation_date :
4480
4481
format : date-time
@@ -4505,7 +4506,6 @@ components:
4505
4506
- objectives
4506
4507
- description
4507
4508
- funders
4508
- - budget
4509
4509
- creation_date
4510
4510
- last_modification
4511
4511
- tags
@@ -4515,6 +4515,7 @@ components:
4515
4515
properties :
4516
4516
budget :
4517
4517
format : int32
4518
+ nullable : true
4518
4519
type : integer
4519
4520
description :
4520
4521
maxLength : 1024
@@ -5967,6 +5968,7 @@ components:
5967
5968
type : string
5968
5969
budget :
5969
5970
format : int32
5971
+ nullable : true
5970
5972
type : integer
5971
5973
business_code :
5972
5974
type : string
@@ -6010,7 +6012,6 @@ components:
6010
6012
- service_code
6011
6013
- creation_date
6012
6014
- last_modification
6013
- - budget
6014
6015
- tags
6015
6016
- state
6016
6017
- study_type
@@ -6025,6 +6026,7 @@ components:
6025
6026
type : string
6026
6027
budget :
6027
6028
format : int32
6029
+ nullable : true
6028
6030
type : integer
6029
6031
business_code :
6030
6032
type : string
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ pub mod tests {
295
295
. service_code ( "BBB" . into ( ) )
296
296
. creation_date ( Utc :: now ( ) . naive_utc ( ) )
297
297
. last_modification ( Utc :: now ( ) . naive_utc ( ) )
298
- . budget ( 0 )
298
+ . budget ( Some ( 0 ) )
299
299
. tags ( Tags :: default ( ) )
300
300
. state ( "some_state" . into ( ) )
301
301
. study_type ( "some_type" . into ( ) )
@@ -313,7 +313,7 @@ pub mod tests {
313
313
. objectives ( "" . to_owned ( ) )
314
314
. description ( "" . to_owned ( ) )
315
315
. funders ( "" . to_owned ( ) )
316
- . budget ( 0 )
316
+ . budget ( Some ( 0 ) )
317
317
. creation_date ( Utc :: now ( ) . naive_utc ( ) )
318
318
. last_modification ( Utc :: now ( ) . naive_utc ( ) )
319
319
. tags ( Tags :: default ( ) ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ pub struct Project {
28
28
pub objectives : String ,
29
29
pub description : String ,
30
30
pub funders : String ,
31
- pub budget : i32 ,
31
+ pub budget : Option < i32 > ,
32
32
pub creation_date : NaiveDateTime ,
33
33
pub last_modification : NaiveDateTime ,
34
34
#[ model( remote = "Vec<Option<String>>" ) ]
@@ -239,7 +239,7 @@ pub mod test {
239
239
// Patch a project
240
240
let mut project = project_fixture. model . clone ( ) ;
241
241
project. name = "update_name" . into ( ) ;
242
- project. budget = 1000 ;
242
+ project. budget = Some ( 1000 ) ;
243
243
project. save ( conn) . await . unwrap ( ) ;
244
244
let project = Project :: retrieve ( conn, project. id ) . await . unwrap ( ) . unwrap ( ) ;
245
245
assert_eq ! ( project. name, String :: from( "update_name" ) ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ pub struct Study {
31
31
pub start_date : Option < NaiveDate > ,
32
32
pub expected_end_date : Option < NaiveDate > ,
33
33
pub actual_end_date : Option < NaiveDate > ,
34
- pub budget : i32 ,
34
+ pub budget : Option < i32 > ,
35
35
#[ model( remote = "Vec<Option<String>>" ) ]
36
36
pub tags : Tags ,
37
37
pub state : String ,
Original file line number Diff line number Diff line change @@ -402,7 +402,7 @@ diesel::table! {
402
402
description -> Varchar ,
403
403
#[ max_length = 255 ]
404
404
funders -> Varchar ,
405
- budget -> Int4 ,
405
+ budget -> Nullable < Int4 > ,
406
406
creation_date -> Timestamptz ,
407
407
last_modification -> Timestamptz ,
408
408
tags -> Array <Nullable <Text >>,
@@ -612,7 +612,7 @@ diesel::table! {
612
612
start_date -> Nullable <Date >,
613
613
expected_end_date -> Nullable <Date >,
614
614
actual_end_date -> Nullable <Date >,
615
- budget -> Int4 ,
615
+ budget -> Nullable < Int4 > ,
616
616
tags -> Array <Nullable <Text >>,
617
617
#[ max_length = 16 ]
618
618
state -> Varchar ,
Original file line number Diff line number Diff line change @@ -76,8 +76,7 @@ struct ProjectCreateForm {
76
76
#[ serde( default ) ]
77
77
#[ schema( max_length = 1024 ) ]
78
78
pub funders : String ,
79
- #[ serde( default ) ]
80
- pub budget : i32 ,
79
+ pub budget : Option < i32 > ,
81
80
/// The id of the image document
82
81
pub image : Option < i64 > ,
83
82
#[ serde( default ) ]
@@ -269,7 +268,7 @@ impl From<ProjectPatchForm> for Changeset<Project> {
269
268
. flat_description ( project. description )
270
269
. flat_objectives ( project. objectives )
271
270
. flat_funders ( project. funders )
272
- . flat_budget ( project. budget )
271
+ . flat_budget ( Some ( project. budget ) )
273
272
. flat_image ( Some ( project. image ) )
274
273
. flat_tags ( project. tags )
275
274
}
Original file line number Diff line number Diff line change @@ -74,8 +74,7 @@ struct StudyCreateForm {
74
74
pub business_code : String ,
75
75
#[ serde( default ) ]
76
76
pub service_code : String ,
77
- #[ serde( default ) ]
78
- pub budget : i32 ,
77
+ pub budget : Option < i32 > ,
79
78
#[ serde( default ) ]
80
79
pub tags : Tags ,
81
80
pub state : String ,
@@ -328,7 +327,7 @@ impl StudyPatchForm {
328
327
. flat_start_date ( Some ( self . start_date ) )
329
328
. flat_expected_end_date ( Some ( self . expected_end_date ) )
330
329
. flat_actual_end_date ( Some ( self . actual_end_date ) )
331
- . flat_budget ( self . budget )
330
+ . flat_budget ( Some ( self . budget ) )
332
331
. flat_tags ( self . tags )
333
332
. flat_state ( self . state )
334
333
. flat_study_type ( self . study_type ) ;
Original file line number Diff line number Diff line change @@ -1926,7 +1926,7 @@ export type ElectrificationsOnPathResponse = {
1926
1926
} ;
1927
1927
export type Tags = string [ ] ;
1928
1928
export type Project = {
1929
- budget : number ;
1929
+ budget ? : number | null ;
1930
1930
creation_date : string ;
1931
1931
description : string ;
1932
1932
funders : string ;
@@ -1958,7 +1958,7 @@ export type Ordering =
1958
1958
| 'LastModifiedDesc'
1959
1959
| 'LastModifiedAsc' ;
1960
1960
export type ProjectCreateForm = {
1961
- budget ?: number ;
1961
+ budget ?: number | null ;
1962
1962
description ?: string ;
1963
1963
funders ?: string ;
1964
1964
/** The id of the image document */
@@ -1979,7 +1979,7 @@ export type ProjectPatchForm = {
1979
1979
} ;
1980
1980
export type Study = {
1981
1981
actual_end_date ?: string | null ;
1982
- budget : number ;
1982
+ budget ? : number | null ;
1983
1983
business_code : string ;
1984
1984
creation_date : string ;
1985
1985
description : string ;
@@ -2013,7 +2013,7 @@ export type StudyResponse = Study & {
2013
2013
} ;
2014
2014
export type StudyCreateForm = {
2015
2015
actual_end_date ?: string | null ;
2016
- budget ?: number ;
2016
+ budget ?: number | null ;
2017
2017
business_code ?: string ;
2018
2018
description ?: string ;
2019
2019
expected_end_date ?: string | null ;
You can’t perform that action at this time.
0 commit comments