wip share
This commit is contained in:
@@ -23,9 +23,13 @@ export async function up() {
|
||||
|
||||
for (const report of reports) {
|
||||
const currentOptions = report.options as IReportOptions | null | undefined;
|
||||
|
||||
|
||||
// Skip if options already exists and is valid
|
||||
if (currentOptions && typeof currentOptions === 'object' && 'type' in currentOptions) {
|
||||
if (
|
||||
currentOptions &&
|
||||
typeof currentOptions === 'object' &&
|
||||
'type' in currentOptions
|
||||
) {
|
||||
skippedCount++;
|
||||
continue;
|
||||
}
|
||||
@@ -61,7 +65,7 @@ export async function up() {
|
||||
console.log(
|
||||
`Migrating report ${report.name} (${report.id}) - chartType: ${report.chartType}`,
|
||||
);
|
||||
|
||||
|
||||
await db.report.update({
|
||||
where: { id: report.id },
|
||||
data: {
|
||||
@@ -84,5 +88,3 @@ export async function up() {
|
||||
`Skipped: ${skippedCount} reports (already migrated or no legacy fields)`,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "public"."share_widgets" (
|
||||
"id" TEXT NOT NULL,
|
||||
"projectId" TEXT NOT NULL,
|
||||
"organizationId" TEXT NOT NULL,
|
||||
"public" BOOLEAN NOT NULL DEFAULT true,
|
||||
"options" JSONB NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "share_widgets_id_key" ON "public"."share_widgets"("id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "public"."share_widgets" ADD CONSTRAINT "share_widgets_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "public"."share_widgets" ADD CONSTRAINT "share_widgets_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."organizations"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -58,6 +58,7 @@ model Organization {
|
||||
ShareOverview ShareOverview[]
|
||||
ShareDashboard ShareDashboard[]
|
||||
ShareReport ShareReport[]
|
||||
ShareWidget ShareWidget[]
|
||||
integrations Integration[]
|
||||
invites Invite[]
|
||||
timezone String?
|
||||
@@ -193,6 +194,7 @@ model Project {
|
||||
share ShareOverview?
|
||||
shareDashboards ShareDashboard[]
|
||||
shareReports ShareReport[]
|
||||
shareWidgets ShareWidget[]
|
||||
meta EventMeta[]
|
||||
references Reference[]
|
||||
access ProjectAccess[]
|
||||
@@ -410,6 +412,21 @@ model ShareReport {
|
||||
@@map("share_reports")
|
||||
}
|
||||
|
||||
model ShareWidget {
|
||||
id String @unique
|
||||
projectId String
|
||||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
organizationId String
|
||||
public Boolean @default(true)
|
||||
/// [IPrismaWidgetOptions]
|
||||
options Json
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@map("share_widgets")
|
||||
}
|
||||
|
||||
model EventMeta {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
name String
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
IIntegrationConfig,
|
||||
INotificationRuleConfig,
|
||||
IProjectFilters,
|
||||
IWidgetOptions,
|
||||
InsightPayload,
|
||||
} from '@openpanel/validation';
|
||||
import type {
|
||||
@@ -20,6 +21,7 @@ declare global {
|
||||
type IPrismaNotificationPayload = INotificationPayload;
|
||||
type IPrismaProjectFilters = IProjectFilters[];
|
||||
type IPrismaProjectInsightPayload = InsightPayload;
|
||||
type IPrismaWidgetOptions = IWidgetOptions;
|
||||
type IPrismaClickhouseEvent = IClickhouseEvent;
|
||||
type IPrismaClickhouseProfile = IClickhouseProfile;
|
||||
type IPrismaClickhouseBotEvent = IClickhouseBotEvent;
|
||||
|
||||
Reference in New Issue
Block a user