Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutgon committed Jul 16, 2024
1 parent 0ea870b commit 6776128
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
3 changes: 3 additions & 0 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
"paths": {
"$/*": ["./src/*"],
"$core/*": ["../../packages/core/src/*"],
"@latitude-data/core": ["../../packages/core/src/*"],
"$jobs/*": ["../../packages/jobs/src/*"],
"@latitude-data/jobs": ["../../packages/jobs/src/*"],
"$ui/*": ["../../packages/web-ui/src/*"],
"@latitude-data/web-ui": ["../../packages/web-ui/src/*"],
"$compiler/*": ["../../packages/compiler/src/*"],
"acorn": ["node_modules/@latitude-data/typescript-config/types/acorn"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS "latitude"."commits" (
"next_commit_id" bigint,
"title" varchar(256),
"description" text,
"workspace_id" bigint NOT NULL,
"project_id" bigint NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "commits_uuid_unique" UNIQUE("uuid")
Expand Down Expand Up @@ -59,7 +59,7 @@ EXCEPTION
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "latitude"."commits" ADD CONSTRAINT "commits_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "latitude"."workspaces"("id") ON DELETE cascade ON UPDATE no action;
ALTER TABLE "latitude"."commits" ADD CONSTRAINT "commits_project_id_workspaces_id_fk" FOREIGN KEY ("project_id") REFERENCES "latitude"."workspaces"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions packages/core/drizzle/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "79ccb0d6-9e01-404e-99bf-8e03c9857c1f",
"id": "cf3e829e-52c2-47fb-89f4-5dd28e3c3d43",
"prevId": "cdf027b2-ec77-4802-8085-bfdcde91f089",
"version": "7",
"dialect": "postgresql",
Expand Down Expand Up @@ -496,8 +496,8 @@
"primaryKey": false,
"notNull": false
},
"workspace_id": {
"name": "workspace_id",
"project_id": {
"name": "project_id",
"type": "bigint",
"primaryKey": false,
"notNull": true
Expand Down Expand Up @@ -549,13 +549,13 @@
"onDelete": "restrict",
"onUpdate": "no action"
},
"commits_workspace_id_workspaces_id_fk": {
"name": "commits_workspace_id_workspaces_id_fk",
"commits_project_id_workspaces_id_fk": {
"name": "commits_project_id_workspaces_id_fk",
"tableFrom": "commits",
"tableTo": "workspaces",
"schemaTo": "latitude",
"columnsFrom": [
"workspace_id"
"project_id"
],
"columnsTo": [
"id"
Expand Down
14 changes: 7 additions & 7 deletions packages/core/drizzle/meta/0003_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "7a35217f-e521-4ce1-a2ae-5af5753339fa",
"prevId": "79ccb0d6-9e01-404e-99bf-8e03c9857c1f",
"id": "eedd6d42-c764-44b7-9e9e-2428f529d3dc",
"prevId": "cf3e829e-52c2-47fb-89f4-5dd28e3c3d43",
"version": "7",
"dialect": "postgresql",
"tables": {
Expand Down Expand Up @@ -496,8 +496,8 @@
"primaryKey": false,
"notNull": false
},
"workspace_id": {
"name": "workspace_id",
"project_id": {
"name": "project_id",
"type": "bigint",
"primaryKey": false,
"notNull": true
Expand Down Expand Up @@ -549,11 +549,11 @@
"onUpdate": "no action",
"onDelete": "restrict"
},
"commits_workspace_id_workspaces_id_fk": {
"name": "commits_workspace_id_workspaces_id_fk",
"commits_project_id_workspaces_id_fk": {
"name": "commits_project_id_workspaces_id_fk",
"tableFrom": "commits",
"columnsFrom": [
"workspace_id"
"project_id"
],
"tableTo": "workspaces",
"schemaTo": "latitude",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
{
"idx": 2,
"version": "7",
"when": 1721122977819,
"tag": "0002_wide_sue_storm",
"when": 1721124730397,
"tag": "0002_windy_wind_dancer",
"breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1721123014037,
"tag": "0003_charming_brood",
"when": 1721124762014,
"tag": "0003_cold_spirit",
"breakpoints": true
}
]
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/schema/models/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
DocumentSnapshot,
documentSnapshots,
latitudeSchema,
Workspace,
Project,
projects,
workspaces,
} from '..'
import { timestamps } from '../schemaHelpers'
Expand All @@ -32,7 +33,7 @@ export const commits = latitudeSchema.table(
),
title: varchar('title', { length: 256 }),
description: text('description'),
workspaceId: bigint('workspace_id', { mode: 'number' })
projectId: bigint('project_id', { mode: 'number' })
.notNull()
.references(() => workspaces.id, { onDelete: 'cascade' }),
...timestamps(),
Expand All @@ -44,10 +45,13 @@ export const commits = latitudeSchema.table(

export const commitRelations = relations(commits, ({ one, many }) => ({
snapshots: many(documentSnapshots, { relationName: 'snapshots' }),
workspace: one(workspaces),
workspace: one(projects, {
fields: [commits.projectId],
references: [projects.id],
}),
}))

export type Commit = InferSelectModel<typeof commits> & {
snapshots: DocumentSnapshot[]
workspace: Workspace
project: Project
}

0 comments on commit 6776128

Please sign in to comment.