File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed
apps/web/scripts/migrations Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change
1
+ import { isGenericEmail } from "@/lib/is-generic-email" ;
1
2
import { prisma } from "@dub/prisma" ;
2
3
import "dotenv-flow/config" ;
3
4
@@ -36,8 +37,10 @@ async function main() {
36
37
const email = workspace . users [ 0 ] ?. user ?. email ;
37
38
const emailDomain = email ? email . split ( "@" ) [ 1 ] ?. toLowerCase ( ) : undefined ;
38
39
39
- if ( ! emailDomain ) {
40
- console . log ( `Workspace ${ workspace . name } has no email domain` ) ;
40
+ if ( ! emailDomain || ( email && isGenericEmail ( email ) ) ) {
41
+ console . log (
42
+ `Workspace ${ workspace . name } 's email domain (${ emailDomain } ) is invalid or generic, skipping...` ,
43
+ ) ;
41
44
continue ;
42
45
}
43
46
@@ -50,18 +53,18 @@ async function main() {
50
53
51
54
console . table ( workspacesToUpdate ) ;
52
55
53
- // await Promise.allSettled(
54
- // workspacesToUpdate.map((workspace) =>
55
- // prisma.project.update({
56
- // where: {
57
- // id: workspace.id,
58
- // },
59
- // data: {
60
- // ssoEmailDomain: workspace.ssoEmailDomain,
61
- // },
62
- // }),
63
- // ),
64
- // );
56
+ await Promise . allSettled (
57
+ workspacesToUpdate . map ( ( workspace ) =>
58
+ prisma . project . update ( {
59
+ where : {
60
+ id : workspace . id ,
61
+ } ,
62
+ data : {
63
+ ssoEmailDomain : workspace . ssoEmailDomain ,
64
+ } ,
65
+ } ) ,
66
+ ) ,
67
+ ) ;
65
68
}
66
69
67
70
main ( ) ;
You can’t perform that action at this time.
0 commit comments