feat(create-turbo): create https://github.com/juliusmarminge/acme-corp
This commit is contained in:
12
packages/db/prisma/enums.ts
Normal file
12
packages/db/prisma/enums.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export const ProjectTier = {
|
||||
FREE: "FREE",
|
||||
PRO: "PRO",
|
||||
} as const;
|
||||
export type ProjectTier = (typeof ProjectTier)[keyof typeof ProjectTier];
|
||||
export const SubscriptionPlan = {
|
||||
FREE: "FREE",
|
||||
STANDARD: "STANDARD",
|
||||
PRO: "PRO",
|
||||
} as const;
|
||||
export type SubscriptionPlan =
|
||||
(typeof SubscriptionPlan)[keyof typeof SubscriptionPlan];
|
||||
83
packages/db/prisma/schema.prisma
Normal file
83
packages/db/prisma/schema.prisma
Normal file
@@ -0,0 +1,83 @@
|
||||
generator kysely {
|
||||
provider = "prisma-kysely"
|
||||
output = "."
|
||||
enumFileName = "enums.ts"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
relationMode = "prisma"
|
||||
}
|
||||
|
||||
enum ProjectTier {
|
||||
FREE
|
||||
PRO
|
||||
}
|
||||
|
||||
model Project {
|
||||
id String @id @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
// A project is tied to a Clerk User or Organization
|
||||
organizationId String? @db.VarChar(36) // uuid v4
|
||||
userId String? @db.VarChar(36) // uuid v4
|
||||
|
||||
name String
|
||||
tier ProjectTier @default(FREE)
|
||||
url String?
|
||||
|
||||
@@index([organizationId])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
enum SubscriptionPlan {
|
||||
FREE
|
||||
STANDARD
|
||||
PRO
|
||||
}
|
||||
|
||||
model Customer {
|
||||
id String @id @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
stripeId String @unique
|
||||
subscriptionId String?
|
||||
clerkUserId String
|
||||
clerkOrganizationId String?
|
||||
name String?
|
||||
plan SubscriptionPlan?
|
||||
paidUntil DateTime?
|
||||
endsAt DateTime?
|
||||
|
||||
@@index([clerkUserId])
|
||||
}
|
||||
|
||||
model ApiKey {
|
||||
id String @id @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
createdAt DateTime @default(now())
|
||||
expiresAt DateTime?
|
||||
lastUsed DateTime?
|
||||
revokedAt DateTime?
|
||||
|
||||
projectId String @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
clerkUserId String @db.VarChar(36) // uuid v4
|
||||
|
||||
name String @default("Secret Key")
|
||||
key String @unique
|
||||
|
||||
@@index([projectId])
|
||||
}
|
||||
|
||||
model Ingestion {
|
||||
id String @id @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
projectId String @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
apiKeyId String @db.VarChar(30) // prefix_ + nanoid (16)
|
||||
|
||||
schema Json
|
||||
hash String @db.VarChar(40) // sha1
|
||||
parent String? @db.VarChar(40) // sha1
|
||||
origin String @db.VarChar(100)
|
||||
|
||||
@@index([projectId])
|
||||
}
|
||||
57
packages/db/prisma/types.ts
Normal file
57
packages/db/prisma/types.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { ColumnType } from "kysely";
|
||||
|
||||
import type { ProjectTier, SubscriptionPlan } from "./enums";
|
||||
|
||||
export type Generated<T> =
|
||||
T extends ColumnType<infer S, infer I, infer U>
|
||||
? ColumnType<S, I | undefined, U>
|
||||
: ColumnType<T, T | undefined, T>;
|
||||
export type Timestamp = ColumnType<Date, Date | string, Date | string>;
|
||||
|
||||
export type ApiKey = {
|
||||
id: string;
|
||||
createdAt: Generated<Timestamp>;
|
||||
expiresAt: Timestamp | null;
|
||||
lastUsed: Timestamp | null;
|
||||
revokedAt: Timestamp | null;
|
||||
projectId: string;
|
||||
clerkUserId: string;
|
||||
name: Generated<string>;
|
||||
key: string;
|
||||
};
|
||||
export type Customer = {
|
||||
id: string;
|
||||
stripeId: string;
|
||||
subscriptionId: string | null;
|
||||
clerkUserId: string;
|
||||
clerkOrganizationId: string | null;
|
||||
name: string | null;
|
||||
plan: SubscriptionPlan | null;
|
||||
paidUntil: Timestamp | null;
|
||||
endsAt: Timestamp | null;
|
||||
};
|
||||
export type Ingestion = {
|
||||
id: string;
|
||||
createdAt: Generated<Timestamp>;
|
||||
projectId: string;
|
||||
apiKeyId: string;
|
||||
schema: unknown;
|
||||
hash: string;
|
||||
parent: string | null;
|
||||
origin: string;
|
||||
};
|
||||
export type Project = {
|
||||
id: string;
|
||||
createdAt: Generated<Timestamp>;
|
||||
organizationId: string | null;
|
||||
userId: string | null;
|
||||
name: string;
|
||||
tier: Generated<ProjectTier>;
|
||||
url: string | null;
|
||||
};
|
||||
export type DB = {
|
||||
ApiKey: ApiKey;
|
||||
Customer: Customer;
|
||||
Ingestion: Ingestion;
|
||||
Project: Project;
|
||||
};
|
||||
Reference in New Issue
Block a user