File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ async function main() {
3333 await transClient . image . deleteMany ( { } ) ;
3434 await transClient . user . deleteMany ( { } ) ;
3535 await transClient . tag . deleteMany ( { } ) ;
36- await transClient . characterRect . deleteMany ( { } ) ;
3736 await transClient . creation . deleteMany ( { where : { isAdmin : true } } ) ;
3837
3938 console . log ( 'Seeding the database...' ) ;
@@ -144,8 +143,13 @@ async function main() {
144143 }
145144 }
146145
147- for ( const data of characters ) {
148- await transClient . characterRect . create ( { data } ) ;
146+ const dbCharacterRectCount = await transClient . characterRect . count ( ) ;
147+ if ( dbCharacterRectCount < characters . length ) {
148+ console . log ( 'Seeding the database with characters...' ) ;
149+ for ( const data of characters ) {
150+ const { name } = data ;
151+ await transClient . characterRect . upsert ( { where : { name } , create : data , update : data } ) ;
152+ }
149153 }
150154 } ,
151155 {
You can’t perform that action at this time.
0 commit comments