Files
app-admin/db/schema/index.ts
2026-03-24 15:46:27 +03:00

48 lines
2.1 KiB
TypeScript

import { pgTable, serial, text, timestamp, varchar, jsonb, integer, boolean } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
password: text("password").notNull(),
role: varchar("role", { length: 20 }).default("user").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
// Uygulamalar Tablosu
export const apps = pgTable("apps", {
id: serial("id").primaryKey(),
name: varchar("name", { length: 100 }).notNull(),
bundleId: varchar("bundle_id", { length: 100 }).notNull().unique(),
appleId: varchar("apple_id", { length: 100 }), // App Store Connect için
platform: varchar("platform", { length: 20 }).default("ios").notNull(), // ios, android, dual
status: varchar("status", { length: 50 }).default("active").notNull(),
iconUrl: text("icon_url"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
// Remote Config & App Settings
export const remoteConfig = pgTable("remote_config", {
id: serial("id").primaryKey(),
appId: integer("app_id").references(() => apps.id, { onDelete: 'cascade' }).notNull(),
configKey: varchar("config_key", { length: 100 }).notNull(),
configValue: jsonb("config_value").notNull(),
description: text("description"),
isActive: boolean("is_active").default(true).notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
// Mevcut items tablosunu "Global İçerik" olarak saklayabiliriz veya genişletebiliriz.
export const items = pgTable("items", {
id: serial("id").primaryKey(),
appId: integer("app_id").references(() => apps.id, { onDelete: 'cascade' }), // Hangi uygulamaya ait?
key: varchar("key", { length: 100 }).notNull(),
title: text("title").notNull(),
content: text("content"),
data: jsonb("data"),
type: varchar("type", { length: 50 }).default("generic").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});