Neon / portal template support (#713)
TODOs: - [x] Do restart when checkout / restore if there is a DB - [x] List all branches (branch id, name, date) - [x] Allow checking out versions with no DB - [x] safeguard to never delete main branches - [x] create app hook for neon template - [x] weird UX with connector on configure panel - [x] tiny neon logo in connector - [x] deploy to vercel - [x] build forgot password page - [x] what about email setup - [x] lots of imgix errors - [x] edit file - db snapshot - [x] DYAD_DISABLE_DB_PUSH - [ ] update portal doc - [x] switch preview branch to be read-only endpoint - [x] disable supabase sys prompt if neon is enabled - [ ] https://payloadcms.com/docs/upload/storage-adapters - [x] need to use main branch... Phase 2? - [x] generate DB migrations
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||
import { integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
export const apps = sqliteTable("apps", {
|
||||
@@ -16,6 +16,9 @@ export const apps = sqliteTable("apps", {
|
||||
githubRepo: text("github_repo"),
|
||||
githubBranch: text("github_branch"),
|
||||
supabaseProjectId: text("supabase_project_id"),
|
||||
neonProjectId: text("neon_project_id"),
|
||||
neonDevelopmentBranchId: text("neon_development_branch_id"),
|
||||
neonPreviewBranchId: text("neon_preview_branch_id"),
|
||||
vercelProjectId: text("vercel_project_id"),
|
||||
vercelProjectName: text("vercel_project_name"),
|
||||
vercelTeamId: text("vercel_team_id"),
|
||||
@@ -51,9 +54,32 @@ export const messages = sqliteTable("messages", {
|
||||
.default(sql`(unixepoch())`),
|
||||
});
|
||||
|
||||
export const versions = sqliteTable(
|
||||
"versions",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
appId: integer("app_id")
|
||||
.notNull()
|
||||
.references(() => apps.id, { onDelete: "cascade" }),
|
||||
commitHash: text("commit_hash").notNull(),
|
||||
neonDbTimestamp: text("neon_db_timestamp"),
|
||||
createdAt: integer("created_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.default(sql`(unixepoch())`),
|
||||
updatedAt: integer("updated_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.default(sql`(unixepoch())`),
|
||||
},
|
||||
(table) => [
|
||||
// Unique constraint to prevent duplicate versions
|
||||
unique("versions_app_commit_unique").on(table.appId, table.commitHash),
|
||||
],
|
||||
);
|
||||
|
||||
// Define relations
|
||||
export const appsRelations = relations(apps, ({ many }) => ({
|
||||
chats: many(chats),
|
||||
versions: many(versions),
|
||||
}));
|
||||
|
||||
export const chatsRelations = relations(chats, ({ many, one }) => ({
|
||||
@@ -124,3 +150,10 @@ export const languageModelsRelations = relations(
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const versionsRelations = relations(versions, ({ one }) => ({
|
||||
app: one(apps, {
|
||||
fields: [versions.appId],
|
||||
references: [apps.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user