Skip to content

Commit

Permalink
Add organizationsId in artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Dec 4, 2024
1 parent 09704f1 commit 4143051
Show file tree
Hide file tree
Showing 7 changed files with 1,808 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/api/artifacts/upload-artifact-url.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default defineEventHandler(async (event) => {
packageMetadata: z.any(),
}).parse)
var appId: string
var orgId: string

const apiKey = getHeader(event, 'API-KEY')
const db = event.context.drizzle
Expand All @@ -23,8 +24,9 @@ export default defineEventHandler(async (event) => {
}

const apiKeyPayload = await verifyToken(event, apiKey, apiAuthKey)
const { appsId } = await findApiKey(db, apiKeyPayload.id, orgName, appName)
const { appsId, organizationId } = await findApiKey(db, apiKeyPayload.id, orgName, appName)
appId = appsId!
orgId = organizationId!
} else {
if (await roleEditNotAllowed(event, orgName)) {
throw createError({
Expand All @@ -33,8 +35,9 @@ export default defineEventHandler(async (event) => {
})
}

const { userApp } = await getUserApp(event, orgName, appName)
const { userApp, userOrg } = await getUserApp(event, orgName, appName)
appId = userApp.id
orgId = userOrg.org!.id
}

const packageData = packageMetadata as {
Expand Down Expand Up @@ -69,6 +72,7 @@ export default defineEventHandler(async (event) => {
versionCode2: packageData?.versionCode?.toString()!,
versionName2: packageData?.versionName!,
appsId: appId,
organizationId: orgId,
releaseNotes: releaseNotes,
releaseId: newReleaseId,
extension: packageData?.extension,
Expand Down
1 change: 1 addition & 0 deletions server/db/drizzle/0048_eager_vindicator.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `artifacts` ADD `organizationId` text;
1 change: 1 addition & 0 deletions server/db/drizzle/0049_open_shockwave.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `artifacts` ALTER COLUMN "organizationId" TO "organizationId" text REFERENCES organizations(id) ON DELETE set null ON UPDATE no action;
Loading

0 comments on commit 4143051

Please sign in to comment.