@@ -66,6 +66,7 @@ export function getProjectQuery(projectId: string): RawQuery<Promise<Omit<Projec
6666 created_at_millis : new Date ( row . createdAt + "Z" ) . getTime ( ) ,
6767 is_production_mode : row . isProductionMode ,
6868 owner_team_id : row . ownerTeamId ,
69+ onboarding_status : row . onboardingStatus ,
6970 } ;
7071 } ,
7172 } ;
@@ -101,22 +102,37 @@ export async function createOrUpdateProjectWithLegacyConfig(
101102 }
102103
103104 const [ projectId , branchId ] = await retryTransaction ( globalPrismaClient , async ( tx ) => {
105+ const onboardingStatusColumnExistsRows = await tx . $queryRaw < Array < { exists : boolean } > > `
106+ SELECT EXISTS (
107+ SELECT 1
108+ FROM information_schema.columns
109+ WHERE table_schema = 'public'
110+ AND table_name = 'Project'
111+ AND column_name = 'onboardingStatus'
112+ ) AS "exists"
113+ ` ;
114+ const onboardingStatusColumnExists = onboardingStatusColumnExistsRows [ 0 ] ?. exists === true ;
115+
104116 let project : Prisma . ProjectGetPayload < { } > ;
105117 let branchId : string ;
106118 if ( options . type === "create" ) {
107119 branchId = DEFAULT_BRANCH_ID ;
120+ const createData : Prisma . ProjectCreateInput = {
121+ id : options . projectId ?? generateUuid ( ) ,
122+ displayName : options . data . display_name ,
123+ description : options . data . description ?? "" ,
124+ isProductionMode : options . data . is_production_mode ?? false ,
125+ ownerTeamId : options . data . owner_team_id ,
126+ logoUrl : logoUrls [ 'logo_url' ] ,
127+ logoFullUrl : logoUrls [ 'logo_full_url' ] ,
128+ logoDarkModeUrl : logoUrls [ 'logo_dark_mode_url' ] ,
129+ logoFullDarkModeUrl : logoUrls [ 'logo_full_dark_mode_url' ] ,
130+ } ;
131+ if ( onboardingStatusColumnExists && options . data . onboarding_status !== undefined ) {
132+ createData . onboardingStatus = options . data . onboarding_status ;
133+ }
108134 project = await tx . project . create ( {
109- data : {
110- id : options . projectId ?? generateUuid ( ) ,
111- displayName : options . data . display_name ,
112- description : options . data . description ?? "" ,
113- isProductionMode : options . data . is_production_mode ?? false ,
114- ownerTeamId : options . data . owner_team_id ,
115- logoUrl : logoUrls [ 'logo_url' ] ,
116- logoFullUrl : logoUrls [ 'logo_full_url' ] ,
117- logoDarkModeUrl : logoUrls [ 'logo_dark_mode_url' ] ,
118- logoFullDarkModeUrl : logoUrls [ 'logo_full_dark_mode_url' ] ,
119- } ,
135+ data : createData ,
120136 } ) ;
121137
122138 await tx . tenancy . create ( {
@@ -138,19 +154,24 @@ export async function createOrUpdateProjectWithLegacyConfig(
138154 throw new KnownErrors . ProjectNotFound ( options . projectId ) ;
139155 }
140156
157+ const updateData : Prisma . ProjectUpdateInput = {
158+ displayName : options . data . display_name ,
159+ description : options . data . description === null ? "" : options . data . description ,
160+ isProductionMode : options . data . is_production_mode ,
161+ logoUrl : logoUrls [ 'logo_url' ] ,
162+ logoFullUrl : logoUrls [ 'logo_full_url' ] ,
163+ logoDarkModeUrl : logoUrls [ 'logo_dark_mode_url' ] ,
164+ logoFullDarkModeUrl : logoUrls [ 'logo_full_dark_mode_url' ] ,
165+ } ;
166+ if ( onboardingStatusColumnExists && options . data . onboarding_status !== undefined ) {
167+ updateData . onboardingStatus = options . data . onboarding_status ;
168+ }
169+
141170 project = await tx . project . update ( {
142171 where : {
143172 id : projectFound . id ,
144173 } ,
145- data : {
146- displayName : options . data . display_name ,
147- description : options . data . description === null ? "" : options . data . description ,
148- isProductionMode : options . data . is_production_mode ,
149- logoUrl : logoUrls [ 'logo_url' ] ,
150- logoFullUrl : logoUrls [ 'logo_full_url' ] ,
151- logoDarkModeUrl : logoUrls [ 'logo_dark_mode_url' ] ,
152- logoFullDarkModeUrl : logoUrls [ 'logo_full_dark_mode_url' ] ,
153- } ,
174+ data : updateData ,
154175 } ) ;
155176 branchId = options . branchId ;
156177 }
0 commit comments