File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 13
13
"lint" : " eslint --fix --ext .ts src" ,
14
14
"db:generate" : " node runWithProvider.js \" npx prisma generate --schema ./prisma/DATABASE_PROVIDER-schema.prisma\" " ,
15
15
"db:deploy" : " node runWithProvider.js \" rm -rf ./prisma/migrations && cp -r ./prisma/DATABASE_PROVIDER-migrations ./prisma/migrations && npx prisma migrate deploy --schema ./prisma/DATABASE_PROVIDER-schema.prisma\" " ,
16
+ "db:deploy:win" : " node runWithProvider.js \" xcopy /E /I prisma\\ DATABASE_PROVIDER-migrations prisma\\ migrations && npx prisma migrate deploy --schema prisma\\ DATABASE_PROVIDER-schema.prisma\" " ,
16
17
"db:studio" : " node runWithProvider.js \" npx prisma studio --schema ./prisma/DATABASE_PROVIDER-schema.prisma\" " ,
17
18
"db:migrate:dev" : " node runWithProvider.js \" rm -rf ./prisma/migrations && cp -r ./prisma/DATABASE_PROVIDER-migrations ./prisma/migrations && npx prisma migrate dev --schema ./prisma/DATABASE_PROVIDER-schema.prisma && cp -r ./prisma/migrations/* ./prisma/DATABASE_PROVIDER-migrations\" "
18
19
},
115
116
"tsconfig-paths" : " ^4.2.0" ,
116
117
"typescript" : " ^5.5.4"
117
118
}
118
- }
119
+ }
Original file line number Diff line number Diff line change 1
1
const dotenv = require ( 'dotenv' ) ;
2
2
const { execSync } = require ( 'child_process' ) ;
3
+ const { existsSync } = require ( 'fs' ) ;
4
+
3
5
dotenv . config ( ) ;
4
6
5
7
const { DATABASE_PROVIDER } = process . env ;
6
- const databaseProviderDefault = DATABASE_PROVIDER ?? " postgresql"
8
+ const databaseProviderDefault = DATABASE_PROVIDER ?? ' postgresql' ;
7
9
8
10
if ( ! DATABASE_PROVIDER ) {
9
- console . error ( `DATABASE_PROVIDER is not set in the .env file, using default: ${ databaseProviderDefault } ` ) ;
10
- // process.exit(1);
11
+ console . warn ( `DATABASE_PROVIDER is not set in the .env file, using default: ${ databaseProviderDefault } ` ) ;
11
12
}
12
13
13
- const command = process . argv
14
+ let command = process . argv
14
15
. slice ( 2 )
15
16
. join ( ' ' )
16
- . replace ( / \D A T A B A S E _ P R O V I D E R / g, databaseProviderDefault ) ;
17
+ . replace ( / D A T A B A S E _ P R O V I D E R / g, databaseProviderDefault ) ;
18
+
19
+ if ( command . includes ( 'rmdir' ) && existsSync ( 'prisma\\migrations' ) ) {
20
+ try {
21
+ execSync ( 'rmdir /S /Q prisma\\migrations' , { stdio : 'inherit' } ) ;
22
+ } catch ( error ) {
23
+ console . error ( `Error removing directory: prisma\\migrations` ) ;
24
+ process . exit ( 1 ) ;
25
+ }
26
+ } else if ( command . includes ( 'rmdir' ) ) {
27
+ console . warn ( `Directory 'prisma\\migrations' does not exist, skipping removal.` ) ;
28
+ }
17
29
18
30
try {
19
31
execSync ( command , { stdio : 'inherit' } ) ;
You can’t perform that action at this time.
0 commit comments