more package declarations
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
-- Create device types enum
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE "DeviceType" AS ENUM('mobile', 'web', 'desktop');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
-- Create platform enum
|
||||
DO $$ BEGIN
|
||||
CREATE TYPE "Platform" AS ENUM('ios', 'android', 'web');
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
|
||||
-- Create device_tokens table
|
||||
CREATE TABLE IF NOT EXISTS "device_tokens" (
|
||||
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
"userId" UUID NOT NULL REFERENCES "users"("id") ON DELETE CASCADE,
|
||||
"deviceType" "DeviceType" NOT NULL DEFAULT 'mobile',
|
||||
"token" TEXT NOT NULL UNIQUE,
|
||||
"platform" "Platform" NOT NULL,
|
||||
"appName" TEXT,
|
||||
"appVersion" TEXT,
|
||||
"osVersion" TEXT,
|
||||
"model" TEXT,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
"lastUsedAt" TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
"createdAt" TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
"updatedAt" TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Create indexes
|
||||
CREATE INDEX IF NOT EXISTS "device_tokens_userId_idx" ON "device_tokens"("userId");
|
||||
CREATE INDEX IF NOT EXISTS "device_tokens_deviceType_idx" ON "device_tokens"("deviceType");
|
||||
CREATE INDEX IF NOT EXISTS "device_tokens_platform_idx" ON "device_tokens"("platform");
|
||||
CREATE INDEX IF NOT EXISTS "device_tokens_isActive_idx" ON "device_tokens"("isActive");
|
||||
@@ -2,7 +2,9 @@
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
"rootDir": "./src",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "Bundler"
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user