From c8e692df8253ffff260ba0c27563bb90013dec1a Mon Sep 17 00:00:00 2001 From: Yunus Date: Sun, 8 Dec 2024 15:17:35 +0700 Subject: [PATCH] Add edge case upload_temp to cleanup stale upload --- components/AppFileUpload.vue | 8 +- .../api/artifacts/upload-artifact-url.post.ts | 37 +- server/api/artifacts/upload-artifact.post.ts | 19 + server/db/drizzle/0050_thick_titania.sql | 6 + server/db/drizzle/0051_narrow_medusa.sql | 1 + server/db/drizzle/0052_acoustic_goliath.sql | 1 + server/db/drizzle/meta/0050_snapshot.json | 936 +++++++++++++++++ server/db/drizzle/meta/0051_snapshot.json | 944 +++++++++++++++++ server/db/drizzle/meta/0052_snapshot.json | 953 ++++++++++++++++++ server/db/drizzle/meta/_journal.json | 21 + server/db/schema.ts | 11 + utils/upload-utils.ts | 4 +- 12 files changed, 2921 insertions(+), 20 deletions(-) create mode 100644 server/db/drizzle/0050_thick_titania.sql create mode 100644 server/db/drizzle/0051_narrow_medusa.sql create mode 100644 server/db/drizzle/0052_acoustic_goliath.sql create mode 100644 server/db/drizzle/meta/0050_snapshot.json create mode 100644 server/db/drizzle/meta/0051_snapshot.json create mode 100644 server/db/drizzle/meta/0052_snapshot.json diff --git a/components/AppFileUpload.vue b/components/AppFileUpload.vue index ed06e9d..b25b800 100644 --- a/components/AppFileUpload.vue +++ b/components/AppFileUpload.vue @@ -63,8 +63,8 @@ watchEffect(() => { }) const { mutateAsync, isPending } = useMutation({ - mutationFn: async (param: { file: File }) => { - const { artifactId } = await onUpload(param.file, 'generate_bundle') + mutationFn: async (param: { file: File, fileApk: string | undefined }) => { + const { artifactId } = await onUpload(param.file, param.fileApk) const groupIds = selectedGroup.value?.map(e => e.id) ?? [] if (artifactId && groupIds && groupIds.length) { await $fetch('/api/update-artifact-groups', { @@ -89,12 +89,14 @@ const submit = async () => { if (!realFile) { return } + const generateFileApk = realFile.name.endsWith('.aab') mutateAsync({ file: realFile, + fileApk: generateFileApk ? 'generate_bundle' : undefined, }) } -const onUpload = async (file: File, fileApk: string) => { +const onUpload = async (file: File, fileApk: string | undefined) => { const data = await uploadArtifact(file, orgName.value, appName.value, releaseNotes.value, fileApk) return { artifactId: data!.artifactId, diff --git a/server/api/artifacts/upload-artifact-url.post.ts b/server/api/artifacts/upload-artifact-url.post.ts index 2c11d4f..6fb1da0 100644 --- a/server/api/artifacts/upload-artifact-url.post.ts +++ b/server/api/artifacts/upload-artifact-url.post.ts @@ -1,7 +1,8 @@ import { findApiKey } from "./upload-artifact.post" export default defineEventHandler(async (event) => { - const { fileKey, apkFileKey, appName, orgName, releaseNotes, packageMetadata, } = await readValidatedBody(event, z.object({ + const { uploadId, fileKey, apkFileKey, appName, orgName, releaseNotes, packageMetadata, } = await readValidatedBody(event, z.object({ + uploadId: z.string().max(128), fileKey: z.string().max(128), apkFileKey: z.string().max(128).nullish(), appName: z.string().trim().min(1).max(128), @@ -63,21 +64,25 @@ export default defineEventHandler(async (event) => { const newReleaseId = (lastArtifact?.releaseId ?? 0) + 1 const now = new Date() const artifactsId = generateId() - await db.insert(tables.artifacts).values({ - id: artifactsId, - createdAt: now, - updatedAt: now, - fileObjectKey: fileKey, - fileObjectApkKey: apkFileKey, - versionCode2: packageData?.versionCode?.toString()!, - versionName2: packageData?.versionName!, - appsId: appId, - organizationId: orgId, - releaseNotes: releaseNotes, - releaseId: newReleaseId, - extension: packageData?.extension, - packageName: packageData?.packageName, - }) + await db.batch([ + db.delete(tables.keyValue) + .where(eq(tables.keyValue.key, uploadId)), + db.insert(tables.artifacts).values({ + id: artifactsId, + createdAt: now, + updatedAt: now, + fileObjectKey: fileKey, + fileObjectApkKey: apkFileKey, + versionCode2: packageData?.versionCode?.toString()!, + versionName2: packageData?.versionName!, + appsId: appId, + organizationId: orgId, + releaseNotes: releaseNotes, + releaseId: newReleaseId, + extension: packageData?.extension, + packageName: packageData?.packageName, + }), + ]) return { artifactId: artifactsId, diff --git a/server/api/artifacts/upload-artifact.post.ts b/server/api/artifacts/upload-artifact.post.ts index c7c4e5b..1a0b687 100644 --- a/server/api/artifacts/upload-artifact.post.ts +++ b/server/api/artifacts/upload-artifact.post.ts @@ -1,5 +1,6 @@ import { count } from "drizzle-orm" import type { LibSQLDatabase } from "drizzle-orm/libsql" +import { uuidv7 } from "uuidv7" export async function findApiKey( db: LibSQLDatabase, @@ -103,7 +104,25 @@ export default defineEventHandler(async (event) => { const { fileKey, signedUrl } = await generateSignedUrlUpload(orgId, appId) const apkUrl = hasFileApk ? await generateSignedUrlUpload(orgId, appId) : undefined + const uploadId = uuidv7() + const now = new Date() + await db.insert(tables.keyValue) + .values({ + key: uploadId, + value: { + fileKey, + orgId: orgId, + appId: appId, + ...(apkUrl ? { + apkFileKey: apkUrl?.fileKey + } : undefined), + }, + group: 'upload_temp', + createdAt: now, + updatedAt: now, + }) return { + uploadId, fileKey, url: signedUrl, apkUrl: apkUrl ? { diff --git a/server/db/drizzle/0050_thick_titania.sql b/server/db/drizzle/0050_thick_titania.sql new file mode 100644 index 0000000..7079712 --- /dev/null +++ b/server/db/drizzle/0050_thick_titania.sql @@ -0,0 +1,6 @@ +CREATE TABLE `key_value` ( + `key` text PRIMARY KEY NOT NULL, + `value` text, + `createdAt` integer, + `updatedAt` integer +); diff --git a/server/db/drizzle/0051_narrow_medusa.sql b/server/db/drizzle/0051_narrow_medusa.sql new file mode 100644 index 0000000..58eb79d --- /dev/null +++ b/server/db/drizzle/0051_narrow_medusa.sql @@ -0,0 +1 @@ +ALTER TABLE `key_value` ADD `group` text DEFAULT 'default'; \ No newline at end of file diff --git a/server/db/drizzle/0052_acoustic_goliath.sql b/server/db/drizzle/0052_acoustic_goliath.sql new file mode 100644 index 0000000..d36213f --- /dev/null +++ b/server/db/drizzle/0052_acoustic_goliath.sql @@ -0,0 +1 @@ +CREATE UNIQUE INDEX `key_value_key_group_unique` ON `key_value` (`key`,`group`); \ No newline at end of file diff --git a/server/db/drizzle/meta/0050_snapshot.json b/server/db/drizzle/meta/0050_snapshot.json new file mode 100644 index 0000000..9de691f --- /dev/null +++ b/server/db/drizzle/meta/0050_snapshot.json @@ -0,0 +1,936 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "5d495969-af1c-495b-80e7-57ef2e249584", + "prevId": "9c047918-7efa-4deb-bfd0-cffd9caf2a08", + "tables": { + "apiKeys": { + "name": "apiKeys", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apiKeys_id_unique": { + "name": "apiKeys_id_unique", + "columns": [ + "id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "apiKeys_organizationId_organizations_id_fk": { + "name": "apiKeys_organizationId_organizations_id_fk", + "tableFrom": "apiKeys", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "apiKeys_appsId_apps_id_fk": { + "name": "apiKeys_appsId_apps_id_fk", + "tableFrom": "apiKeys", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "apps": { + "name": "apps", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "osType": { + "name": "osType", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationsId": { + "name": "organizationsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apps_id_unique": { + "name": "apps_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "apps_organizationsId_name_unique": { + "name": "apps_organizationsId_name_unique", + "columns": [ + "organizationsId", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "apps_organizationsId_organizations_id_fk": { + "name": "apps_organizationsId_organizations_id_fk", + "tableFrom": "apps", + "tableTo": "organizations", + "columnsFrom": [ + "organizationsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifacts": { + "name": "artifacts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "fileObjectKey": { + "name": "fileObjectKey", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_object_apk_key": { + "name": "file_object_apk_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "versionName2": { + "name": "versionName2", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "versionCode2": { + "name": "versionCode2", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "releaseNotes": { + "name": "releaseNotes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "releaseId": { + "name": "releaseId", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "extension": { + "name": "extension", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "packageName": { + "name": "packageName", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "artifacts_id_unique": { + "name": "artifacts_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "artifacts_appsId_releaseId_unique": { + "name": "artifacts_appsId_releaseId_unique", + "columns": [ + "appsId", + "releaseId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifacts_appsId_apps_id_fk": { + "name": "artifacts_appsId_apps_id_fk", + "tableFrom": "artifacts", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "artifacts_organizationId_organizations_id_fk": { + "name": "artifacts_organizationId_organizations_id_fk", + "tableFrom": "artifacts", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifactsGroups": { + "name": "artifactsGroups", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "publicId": { + "name": "publicId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "isPublic": { + "name": "isPublic", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "artifactsGroups_id_unique": { + "name": "artifactsGroups_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "artifactsGroups_appsId_name_unique": { + "name": "artifactsGroups_appsId_name_unique", + "columns": [ + "appsId", + "name" + ], + "isUnique": true + }, + "artifactsGroups_appsId_name_publicId_unique": { + "name": "artifactsGroups_appsId_name_publicId_unique", + "columns": [ + "appsId", + "name", + "publicId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifactsGroups_appsId_apps_id_fk": { + "name": "artifactsGroups_appsId_apps_id_fk", + "tableFrom": "artifactsGroups", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifactsGroupsManager": { + "name": "artifactsGroupsManager", + "columns": { + "artifactsId": { + "name": "artifactsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifactsGroupsId": { + "name": "artifactsGroupsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "artifactsGroupsManager_artifactsId_artifactsGroupsId_unique": { + "name": "artifactsGroupsManager_artifactsId_artifactsGroupsId_unique", + "columns": [ + "artifactsId", + "artifactsGroupsId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifactsGroupsManager_artifactsId_artifacts_id_fk": { + "name": "artifactsGroupsManager_artifactsId_artifacts_id_fk", + "tableFrom": "artifactsGroupsManager", + "tableTo": "artifacts", + "columnsFrom": [ + "artifactsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "artifactsGroupsManager_artifactsGroupsId_artifactsGroups_id_fk": { + "name": "artifactsGroupsManager_artifactsGroupsId_artifactsGroups_id_fk", + "tableFrom": "artifactsGroupsManager", + "tableTo": "artifactsGroups", + "columnsFrom": [ + "artifactsGroupsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "grouptester": { + "name": "grouptester", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "testerId": { + "name": "testerId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifactGroupId": { + "name": "artifactGroupId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "grouptester_id_unique": { + "name": "grouptester_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "testerId_orgId_appId_groupId": { + "name": "testerId_orgId_appId_groupId", + "columns": [ + "testerId", + "organizationId", + "appsId", + "artifactGroupId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "grouptester_testerId_users_id_fk": { + "name": "grouptester_testerId_users_id_fk", + "tableFrom": "grouptester", + "tableTo": "users", + "columnsFrom": [ + "testerId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_organizationId_organizations_id_fk": { + "name": "grouptester_organizationId_organizations_id_fk", + "tableFrom": "grouptester", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_appsId_apps_id_fk": { + "name": "grouptester_appsId_apps_id_fk", + "tableFrom": "grouptester", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_artifactGroupId_artifactsGroups_id_fk": { + "name": "grouptester_artifactGroupId_artifactsGroups_id_fk", + "tableFrom": "grouptester", + "tableTo": "artifactsGroups", + "columnsFrom": [ + "artifactGroupId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "key_value": { + "name": "key_value", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organizations": { + "name": "organizations", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "organizations_id_unique": { + "name": "organizations_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "organizations_name_unique": { + "name": "organizations_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organizationsPeople": { + "name": "organizationsPeople", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "organizationsPeople_userId_organizationId_unique": { + "name": "organizationsPeople_userId_organizationId_unique", + "columns": [ + "userId", + "organizationId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "organizationsPeople_userId_users_id_fk": { + "name": "organizationsPeople_userId_users_id_fk", + "tableFrom": "organizationsPeople", + "tableTo": "users", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "organizationsPeople_organizationId_organizations_id_fk": { + "name": "organizationsPeople_organizationId_organizations_id_fk", + "tableFrom": "organizationsPeople", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "purgeAppArtifact": { + "name": "purgeAppArtifact", + "columns": { + "orgId": { + "name": "orgId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appId": { + "name": "appId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hasArtifact": { + "name": "hasArtifact", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appName": { + "name": "appName", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch('subsecond') * 1000)" + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch('subsecond') * 1000)" + } + }, + "indexes": { + "idx_createdAt": { + "name": "idx_createdAt", + "columns": [ + "createdAt" + ], + "isUnique": false + }, + "idx_hasArtifact": { + "name": "idx_hasArtifact", + "columns": [ + "hasArtifact" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "purgeAppArtifact_orgId_appId_pk": { + "columns": [ + "orgId", + "appId" + ], + "name": "purgeAppArtifact_orgId_appId_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "providerUserId": { + "name": "providerUserId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_id_unique": { + "name": "users_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "users_providerUserId_unique": { + "name": "users_providerUserId_unique", + "columns": [ + "providerUserId" + ], + "isUnique": true + }, + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "providerUserId": { + "name": "providerUserId", + "columns": [ + "providerUserId" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/db/drizzle/meta/0051_snapshot.json b/server/db/drizzle/meta/0051_snapshot.json new file mode 100644 index 0000000..04faaa1 --- /dev/null +++ b/server/db/drizzle/meta/0051_snapshot.json @@ -0,0 +1,944 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "8cbbbd7f-14af-4ad6-aba7-080f813d5fc1", + "prevId": "5d495969-af1c-495b-80e7-57ef2e249584", + "tables": { + "apiKeys": { + "name": "apiKeys", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apiKeys_id_unique": { + "name": "apiKeys_id_unique", + "columns": [ + "id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "apiKeys_organizationId_organizations_id_fk": { + "name": "apiKeys_organizationId_organizations_id_fk", + "tableFrom": "apiKeys", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "apiKeys_appsId_apps_id_fk": { + "name": "apiKeys_appsId_apps_id_fk", + "tableFrom": "apiKeys", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "apps": { + "name": "apps", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "osType": { + "name": "osType", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationsId": { + "name": "organizationsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apps_id_unique": { + "name": "apps_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "apps_organizationsId_name_unique": { + "name": "apps_organizationsId_name_unique", + "columns": [ + "organizationsId", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "apps_organizationsId_organizations_id_fk": { + "name": "apps_organizationsId_organizations_id_fk", + "tableFrom": "apps", + "tableTo": "organizations", + "columnsFrom": [ + "organizationsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifacts": { + "name": "artifacts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "fileObjectKey": { + "name": "fileObjectKey", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_object_apk_key": { + "name": "file_object_apk_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "versionName2": { + "name": "versionName2", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "versionCode2": { + "name": "versionCode2", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "releaseNotes": { + "name": "releaseNotes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "releaseId": { + "name": "releaseId", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "extension": { + "name": "extension", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "packageName": { + "name": "packageName", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "artifacts_id_unique": { + "name": "artifacts_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "artifacts_appsId_releaseId_unique": { + "name": "artifacts_appsId_releaseId_unique", + "columns": [ + "appsId", + "releaseId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifacts_appsId_apps_id_fk": { + "name": "artifacts_appsId_apps_id_fk", + "tableFrom": "artifacts", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "artifacts_organizationId_organizations_id_fk": { + "name": "artifacts_organizationId_organizations_id_fk", + "tableFrom": "artifacts", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifactsGroups": { + "name": "artifactsGroups", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "publicId": { + "name": "publicId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "isPublic": { + "name": "isPublic", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "artifactsGroups_id_unique": { + "name": "artifactsGroups_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "artifactsGroups_appsId_name_unique": { + "name": "artifactsGroups_appsId_name_unique", + "columns": [ + "appsId", + "name" + ], + "isUnique": true + }, + "artifactsGroups_appsId_name_publicId_unique": { + "name": "artifactsGroups_appsId_name_publicId_unique", + "columns": [ + "appsId", + "name", + "publicId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifactsGroups_appsId_apps_id_fk": { + "name": "artifactsGroups_appsId_apps_id_fk", + "tableFrom": "artifactsGroups", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifactsGroupsManager": { + "name": "artifactsGroupsManager", + "columns": { + "artifactsId": { + "name": "artifactsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifactsGroupsId": { + "name": "artifactsGroupsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "artifactsGroupsManager_artifactsId_artifactsGroupsId_unique": { + "name": "artifactsGroupsManager_artifactsId_artifactsGroupsId_unique", + "columns": [ + "artifactsId", + "artifactsGroupsId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifactsGroupsManager_artifactsId_artifacts_id_fk": { + "name": "artifactsGroupsManager_artifactsId_artifacts_id_fk", + "tableFrom": "artifactsGroupsManager", + "tableTo": "artifacts", + "columnsFrom": [ + "artifactsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "artifactsGroupsManager_artifactsGroupsId_artifactsGroups_id_fk": { + "name": "artifactsGroupsManager_artifactsGroupsId_artifactsGroups_id_fk", + "tableFrom": "artifactsGroupsManager", + "tableTo": "artifactsGroups", + "columnsFrom": [ + "artifactsGroupsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "grouptester": { + "name": "grouptester", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "testerId": { + "name": "testerId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifactGroupId": { + "name": "artifactGroupId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "grouptester_id_unique": { + "name": "grouptester_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "testerId_orgId_appId_groupId": { + "name": "testerId_orgId_appId_groupId", + "columns": [ + "testerId", + "organizationId", + "appsId", + "artifactGroupId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "grouptester_testerId_users_id_fk": { + "name": "grouptester_testerId_users_id_fk", + "tableFrom": "grouptester", + "tableTo": "users", + "columnsFrom": [ + "testerId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_organizationId_organizations_id_fk": { + "name": "grouptester_organizationId_organizations_id_fk", + "tableFrom": "grouptester", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_appsId_apps_id_fk": { + "name": "grouptester_appsId_apps_id_fk", + "tableFrom": "grouptester", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_artifactGroupId_artifactsGroups_id_fk": { + "name": "grouptester_artifactGroupId_artifactsGroups_id_fk", + "tableFrom": "grouptester", + "tableTo": "artifactsGroups", + "columnsFrom": [ + "artifactGroupId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "key_value": { + "name": "key_value", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "group": { + "name": "group", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'default'" + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organizations": { + "name": "organizations", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "organizations_id_unique": { + "name": "organizations_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "organizations_name_unique": { + "name": "organizations_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organizationsPeople": { + "name": "organizationsPeople", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "organizationsPeople_userId_organizationId_unique": { + "name": "organizationsPeople_userId_organizationId_unique", + "columns": [ + "userId", + "organizationId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "organizationsPeople_userId_users_id_fk": { + "name": "organizationsPeople_userId_users_id_fk", + "tableFrom": "organizationsPeople", + "tableTo": "users", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "organizationsPeople_organizationId_organizations_id_fk": { + "name": "organizationsPeople_organizationId_organizations_id_fk", + "tableFrom": "organizationsPeople", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "purgeAppArtifact": { + "name": "purgeAppArtifact", + "columns": { + "orgId": { + "name": "orgId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appId": { + "name": "appId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hasArtifact": { + "name": "hasArtifact", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appName": { + "name": "appName", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch('subsecond') * 1000)" + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch('subsecond') * 1000)" + } + }, + "indexes": { + "idx_createdAt": { + "name": "idx_createdAt", + "columns": [ + "createdAt" + ], + "isUnique": false + }, + "idx_hasArtifact": { + "name": "idx_hasArtifact", + "columns": [ + "hasArtifact" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "purgeAppArtifact_orgId_appId_pk": { + "columns": [ + "orgId", + "appId" + ], + "name": "purgeAppArtifact_orgId_appId_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "providerUserId": { + "name": "providerUserId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_id_unique": { + "name": "users_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "users_providerUserId_unique": { + "name": "users_providerUserId_unique", + "columns": [ + "providerUserId" + ], + "isUnique": true + }, + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "providerUserId": { + "name": "providerUserId", + "columns": [ + "providerUserId" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/db/drizzle/meta/0052_snapshot.json b/server/db/drizzle/meta/0052_snapshot.json new file mode 100644 index 0000000..39623fb --- /dev/null +++ b/server/db/drizzle/meta/0052_snapshot.json @@ -0,0 +1,953 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "8e90596f-cab4-474a-b085-7a568770dd8e", + "prevId": "8cbbbd7f-14af-4ad6-aba7-080f813d5fc1", + "tables": { + "apiKeys": { + "name": "apiKeys", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apiKeys_id_unique": { + "name": "apiKeys_id_unique", + "columns": [ + "id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "apiKeys_organizationId_organizations_id_fk": { + "name": "apiKeys_organizationId_organizations_id_fk", + "tableFrom": "apiKeys", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "apiKeys_appsId_apps_id_fk": { + "name": "apiKeys_appsId_apps_id_fk", + "tableFrom": "apiKeys", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "apps": { + "name": "apps", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "osType": { + "name": "osType", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationsId": { + "name": "organizationsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "apps_id_unique": { + "name": "apps_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "apps_organizationsId_name_unique": { + "name": "apps_organizationsId_name_unique", + "columns": [ + "organizationsId", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "apps_organizationsId_organizations_id_fk": { + "name": "apps_organizationsId_organizations_id_fk", + "tableFrom": "apps", + "tableTo": "organizations", + "columnsFrom": [ + "organizationsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifacts": { + "name": "artifacts", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "fileObjectKey": { + "name": "fileObjectKey", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_object_apk_key": { + "name": "file_object_apk_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "versionName2": { + "name": "versionName2", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "versionCode2": { + "name": "versionCode2", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "releaseNotes": { + "name": "releaseNotes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "releaseId": { + "name": "releaseId", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "extension": { + "name": "extension", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "packageName": { + "name": "packageName", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "artifacts_id_unique": { + "name": "artifacts_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "artifacts_appsId_releaseId_unique": { + "name": "artifacts_appsId_releaseId_unique", + "columns": [ + "appsId", + "releaseId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifacts_appsId_apps_id_fk": { + "name": "artifacts_appsId_apps_id_fk", + "tableFrom": "artifacts", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "artifacts_organizationId_organizations_id_fk": { + "name": "artifacts_organizationId_organizations_id_fk", + "tableFrom": "artifacts", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifactsGroups": { + "name": "artifactsGroups", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "publicId": { + "name": "publicId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "isPublic": { + "name": "isPublic", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "artifactsGroups_id_unique": { + "name": "artifactsGroups_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "artifactsGroups_appsId_name_unique": { + "name": "artifactsGroups_appsId_name_unique", + "columns": [ + "appsId", + "name" + ], + "isUnique": true + }, + "artifactsGroups_appsId_name_publicId_unique": { + "name": "artifactsGroups_appsId_name_publicId_unique", + "columns": [ + "appsId", + "name", + "publicId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifactsGroups_appsId_apps_id_fk": { + "name": "artifactsGroups_appsId_apps_id_fk", + "tableFrom": "artifactsGroups", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifactsGroupsManager": { + "name": "artifactsGroupsManager", + "columns": { + "artifactsId": { + "name": "artifactsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifactsGroupsId": { + "name": "artifactsGroupsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "artifactsGroupsManager_artifactsId_artifactsGroupsId_unique": { + "name": "artifactsGroupsManager_artifactsId_artifactsGroupsId_unique", + "columns": [ + "artifactsId", + "artifactsGroupsId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "artifactsGroupsManager_artifactsId_artifacts_id_fk": { + "name": "artifactsGroupsManager_artifactsId_artifacts_id_fk", + "tableFrom": "artifactsGroupsManager", + "tableTo": "artifacts", + "columnsFrom": [ + "artifactsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "artifactsGroupsManager_artifactsGroupsId_artifactsGroups_id_fk": { + "name": "artifactsGroupsManager_artifactsGroupsId_artifactsGroups_id_fk", + "tableFrom": "artifactsGroupsManager", + "tableTo": "artifactsGroups", + "columnsFrom": [ + "artifactsGroupsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "grouptester": { + "name": "grouptester", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "testerId": { + "name": "testerId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "appsId": { + "name": "appsId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifactGroupId": { + "name": "artifactGroupId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "grouptester_id_unique": { + "name": "grouptester_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "testerId_orgId_appId_groupId": { + "name": "testerId_orgId_appId_groupId", + "columns": [ + "testerId", + "organizationId", + "appsId", + "artifactGroupId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "grouptester_testerId_users_id_fk": { + "name": "grouptester_testerId_users_id_fk", + "tableFrom": "grouptester", + "tableTo": "users", + "columnsFrom": [ + "testerId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_organizationId_organizations_id_fk": { + "name": "grouptester_organizationId_organizations_id_fk", + "tableFrom": "grouptester", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_appsId_apps_id_fk": { + "name": "grouptester_appsId_apps_id_fk", + "tableFrom": "grouptester", + "tableTo": "apps", + "columnsFrom": [ + "appsId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "grouptester_artifactGroupId_artifactsGroups_id_fk": { + "name": "grouptester_artifactGroupId_artifactsGroups_id_fk", + "tableFrom": "grouptester", + "tableTo": "artifactsGroups", + "columnsFrom": [ + "artifactGroupId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "key_value": { + "name": "key_value", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "group": { + "name": "group", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'default'" + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "key_value_key_group_unique": { + "name": "key_value_key_group_unique", + "columns": [ + "key", + "group" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organizations": { + "name": "organizations", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "displayName": { + "name": "displayName", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "organizations_id_unique": { + "name": "organizations_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "organizations_name_unique": { + "name": "organizations_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "organizationsPeople": { + "name": "organizationsPeople", + "columns": { + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "organizationId": { + "name": "organizationId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "organizationsPeople_userId_organizationId_unique": { + "name": "organizationsPeople_userId_organizationId_unique", + "columns": [ + "userId", + "organizationId" + ], + "isUnique": true + } + }, + "foreignKeys": { + "organizationsPeople_userId_users_id_fk": { + "name": "organizationsPeople_userId_users_id_fk", + "tableFrom": "organizationsPeople", + "tableTo": "users", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "organizationsPeople_organizationId_organizations_id_fk": { + "name": "organizationsPeople_organizationId_organizations_id_fk", + "tableFrom": "organizationsPeople", + "tableTo": "organizations", + "columnsFrom": [ + "organizationId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "purgeAppArtifact": { + "name": "purgeAppArtifact", + "columns": { + "orgId": { + "name": "orgId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appId": { + "name": "appId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hasArtifact": { + "name": "hasArtifact", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "appName": { + "name": "appName", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch('subsecond') * 1000)" + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch('subsecond') * 1000)" + } + }, + "indexes": { + "idx_createdAt": { + "name": "idx_createdAt", + "columns": [ + "createdAt" + ], + "isUnique": false + }, + "idx_hasArtifact": { + "name": "idx_hasArtifact", + "columns": [ + "hasArtifact" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "purgeAppArtifact_orgId_appId_pk": { + "columns": [ + "orgId", + "appId" + ], + "name": "purgeAppArtifact_orgId_appId_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "providerUserId": { + "name": "providerUserId", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_id_unique": { + "name": "users_id_unique", + "columns": [ + "id" + ], + "isUnique": true + }, + "users_providerUserId_unique": { + "name": "users_providerUserId_unique", + "columns": [ + "providerUserId" + ], + "isUnique": true + }, + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "providerUserId": { + "name": "providerUserId", + "columns": [ + "providerUserId" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/db/drizzle/meta/_journal.json b/server/db/drizzle/meta/_journal.json index 2a5d5f8..bedd655 100644 --- a/server/db/drizzle/meta/_journal.json +++ b/server/db/drizzle/meta/_journal.json @@ -351,6 +351,27 @@ "when": 1733354584990, "tag": "0049_open_shockwave", "breakpoints": true + }, + { + "idx": 50, + "version": "6", + "when": 1733643937613, + "tag": "0050_thick_titania", + "breakpoints": true + }, + { + "idx": 51, + "version": "6", + "when": 1733644168217, + "tag": "0051_narrow_medusa", + "breakpoints": true + }, + { + "idx": 52, + "version": "6", + "when": 1733644877089, + "tag": "0052_acoustic_goliath", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/db/schema.ts b/server/db/schema.ts index c0a8b2b..f6e725f 100644 --- a/server/db/schema.ts +++ b/server/db/schema.ts @@ -236,3 +236,14 @@ export const purgeAppArtifact = sqliteTable('purgeAppArtifact', { idx_createdAt: index('idx_createdAt').on(t.createdAt), idx_hasArtifact: index('idx_hasArtifact').on(t.hasArtifact), })) + +export const keyValue = sqliteTable('key_value', { + key: text('key').primaryKey(), + group: text('group').default('default'), + value: text('value', { + mode: 'json', + }), + ...timeColumns, +}, (t) => ({ + key_value_group_key: unique().on(t.key, t.group), +})) diff --git a/utils/upload-utils.ts b/utils/upload-utils.ts index 5ead872..1d25f6d 100644 --- a/utils/upload-utils.ts +++ b/utils/upload-utils.ts @@ -16,6 +16,7 @@ export const myFetch = ofetch.create({ }) export type UploadArtifactResponse = { + uploadId: string, url: string, fileKey: string, apkUrl: { @@ -35,7 +36,7 @@ export async function uploadArtifact( if (!packageMetadata) { throw 'Cannot read package file' } - const { url, fileKey, apkUrl } = await myFetch('/api/artifacts/upload-artifact', { + const { url, fileKey, apkUrl, uploadId } = await myFetch('/api/artifacts/upload-artifact', { method: 'post', body: { orgName: orgName, @@ -77,6 +78,7 @@ export async function uploadArtifact( const data = await myFetch('/api/artifacts/upload-artifact-url', { method: 'post', body: { + uploadId, fileKey, apkFileKey: apkUrl?.apkFileKey, appName: appName,