Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,46 @@ export default defineNuxtConfig({

nitro: {
modules: ['nitro-graphql'],
hooks: {
compiled: async () => {
// Migration dosyalarını build output'a kopyala
const { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } = await import('node:fs')
const { join } = await import('node:path')

const copyDirectory = (source: string, target: string) => {
if (!existsSync(source))
return

const files = readdirSync(source)

for (const file of files) {
const sourcePath = join(source, file)
const targetPath = join(target, file)

if (statSync(sourcePath).isDirectory()) {
if (!existsSync(targetPath)) {
mkdirSync(targetPath, { recursive: true })
}
copyDirectory(sourcePath, targetPath)
}
else {
copyFileSync(sourcePath, targetPath)
}
}
}

const migrationsSource = './server/database/migrations'
const migrationsTarget = './.output/server/migrations'

if (existsSync(migrationsSource)) {
console.log('[build] Copying migration files to build directory...')
// Hedef klasörü oluştur
mkdirSync(migrationsTarget, { recursive: true })
copyDirectory(migrationsSource, migrationsTarget)
console.log('[build] ✅ Migration files copied successfully')
}
},
},
graphql: {
framework: 'graphql-yoga',
codegen: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"db:push": "drizzle-kit push --config ./server/drizzle.config.ts",
"db:drop": "drizzle-kit drop --config ./server/drizzle.config.ts",
"db:up": "drizzle-kit up --config ./server/drizzle.config.ts",
"db:pull": "drizzle-kit pull --config ./server/drizzle.config.ts",
"db:check": "drizzle-kit check --config ./server/drizzle.config.ts",
"db:studio": "drizzle-kit studio",
"test": "vitest",
Expand Down
152 changes: 152 additions & 0 deletions server/database/migrations/0000_jazzy_jackpot.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'delivery_status') THEN
CREATE TYPE "public"."delivery_status" AS ENUM('PENDING', 'SENT', 'DELIVERED', 'FAILED', 'CLICKED');
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'device_status') THEN
CREATE TYPE "public"."device_status" AS ENUM('ACTIVE', 'INACTIVE', 'EXPIRED');
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'notification_status') THEN
CREATE TYPE "public"."notification_status" AS ENUM('PENDING', 'SENT', 'DELIVERED', 'FAILED', 'SCHEDULED');
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'platform') THEN
CREATE TYPE "public"."platform" AS ENUM('IOS', 'ANDROID', 'WEB');
END IF;
END $$;--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "apiKey" (
"id" uuid PRIMARY KEY NOT NULL,
"appId" uuid NOT NULL,
"name" text NOT NULL,
"key" text NOT NULL,
"permissions" jsonb,
"isActive" boolean DEFAULT true,
"lastUsedAt" timestamp(3) with time zone,
"expiresAt" timestamp(3) with time zone,
"createdAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
CONSTRAINT "apiKey_key_unique" UNIQUE("key")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "app" (
"id" uuid PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"slug" text NOT NULL,
"description" text,
"apiKey" text NOT NULL,
"fcmServerKey" text,
"fcmProjectId" text,
"apnsCertificate" text,
"apnsKeyId" text,
"apnsTeamId" text,
"bundleId" text,
"vapidPublicKey" text,
"vapidPrivateKey" text,
"vapidSubject" text,
"isActive" boolean DEFAULT true NOT NULL,
"createdAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
CONSTRAINT "app_slug_unique" UNIQUE("slug"),
CONSTRAINT "app_apiKey_unique" UNIQUE("apiKey")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "deliveryLog" (
"id" uuid PRIMARY KEY NOT NULL,
"notificationId" uuid NOT NULL,
"deviceId" uuid NOT NULL,
"status" "delivery_status" NOT NULL,
"providerResponse" jsonb,
"errorMessage" text,
"attemptCount" integer DEFAULT 1,
"sentAt" timestamp(3) with time zone,
"deliveredAt" timestamp(3) with time zone,
"openedAt" timestamp(3) with time zone,
"clickedAt" timestamp(3) with time zone,
"platform" text,
"userAgent" text,
"appVersion" text,
"osVersion" text,
"createdAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
CONSTRAINT "deliveryLog_notificationId_deviceId_unique" UNIQUE("notificationId","deviceId")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "device" (
"id" uuid PRIMARY KEY NOT NULL,
"appId" uuid NOT NULL,
"token" text NOT NULL,
"platform" "platform" NOT NULL,
"userId" text,
"status" "device_status" DEFAULT 'ACTIVE' NOT NULL,
"metadata" jsonb,
"lastSeenAt" timestamp(3) with time zone,
"createdAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
CONSTRAINT "device_appId_token_userId_unique" UNIQUE("appId","token","userId")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "notification" (
"id" uuid PRIMARY KEY NOT NULL,
"appId" uuid NOT NULL,
"title" text NOT NULL,
"body" text NOT NULL,
"data" jsonb,
"badge" integer,
"sound" text,
"clickAction" text,
"icon" text,
"image" text,
"imageUrl" text,
"targetDevices" jsonb,
"platforms" jsonb,
"scheduledAt" timestamp(3) with time zone,
"expiresAt" timestamp(3) with time zone,
"status" "notification_status" DEFAULT 'PENDING' NOT NULL,
"totalTargets" integer DEFAULT 0 NOT NULL,
"totalSent" integer DEFAULT 0 NOT NULL,
"totalDelivered" integer DEFAULT 0 NOT NULL,
"totalFailed" integer DEFAULT 0 NOT NULL,
"totalClicked" integer DEFAULT 0 NOT NULL,
"sentAt" timestamp(3) with time zone,
"createdAt" timestamp(3) with time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp(3) with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE constraint_name = 'apiKey_appId_app_id_fk') THEN
ALTER TABLE "apiKey" ADD CONSTRAINT "apiKey_appId_app_id_fk" FOREIGN KEY ("appId") REFERENCES "public"."app"("id") ON DELETE cascade ON UPDATE no action;
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE constraint_name = 'deliveryLog_notificationId_notification_id_fk') THEN
ALTER TABLE "deliveryLog" ADD CONSTRAINT "deliveryLog_notificationId_notification_id_fk" FOREIGN KEY ("notificationId") REFERENCES "public"."notification"("id") ON DELETE cascade ON UPDATE no action;
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE constraint_name = 'deliveryLog_deviceId_device_id_fk') THEN
ALTER TABLE "deliveryLog" ADD CONSTRAINT "deliveryLog_deviceId_device_id_fk" FOREIGN KEY ("deviceId") REFERENCES "public"."device"("id") ON DELETE cascade ON UPDATE no action;
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE constraint_name = 'device_appId_app_id_fk') THEN
ALTER TABLE "device" ADD CONSTRAINT "device_appId_app_id_fk" FOREIGN KEY ("appId") REFERENCES "public"."app"("id") ON DELETE cascade ON UPDATE no action;
END IF;
END $$;--> statement-breakpoint
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE constraint_name = 'notification_appId_app_id_fk') THEN
ALTER TABLE "notification" ADD CONSTRAINT "notification_appId_app_id_fk" FOREIGN KEY ("appId") REFERENCES "public"."app"("id") ON DELETE cascade ON UPDATE no action;
END IF;
END $$;
95 changes: 0 additions & 95 deletions server/database/migrations/0000_open_master_mold.sql

This file was deleted.

6 changes: 0 additions & 6 deletions server/database/migrations/0001_flowery_dexter_bennett.sql

This file was deleted.

1 change: 0 additions & 1 deletion server/database/migrations/0002_dapper_moon_knight.sql

This file was deleted.

54 changes: 0 additions & 54 deletions server/database/migrations/0003_warm_legion.sql

This file was deleted.

1 change: 0 additions & 1 deletion server/database/migrations/0004_dry_switch.sql

This file was deleted.

Loading