From 677612894a3edcc1db715f16945e218bdb1482b7 Mon Sep 17 00:00:00 2001 From: andresgutgon Date: Tue, 16 Jul 2024 12:13:10 +0200 Subject: [PATCH] feat: wip --- apps/web/tsconfig.json | 3 +++ ...de_sue_storm.sql => 0002_windy_wind_dancer.sql} | 4 ++-- ...003_charming_brood.sql => 0003_cold_spirit.sql} | 0 packages/core/drizzle/meta/0002_snapshot.json | 12 ++++++------ packages/core/drizzle/meta/0003_snapshot.json | 14 +++++++------- packages/core/drizzle/meta/_journal.json | 8 ++++---- packages/core/src/schema/models/commits.ts | 12 ++++++++---- 7 files changed, 30 insertions(+), 23 deletions(-) rename packages/core/drizzle/{0002_wide_sue_storm.sql => 0002_windy_wind_dancer.sql} (94%) rename packages/core/drizzle/{0003_charming_brood.sql => 0003_cold_spirit.sql} (100%) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 19119173b..c6f2a1e22 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -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"] } diff --git a/packages/core/drizzle/0002_wide_sue_storm.sql b/packages/core/drizzle/0002_windy_wind_dancer.sql similarity index 94% rename from packages/core/drizzle/0002_wide_sue_storm.sql rename to packages/core/drizzle/0002_windy_wind_dancer.sql index 3920edeb0..91dae5bd0 100644 --- a/packages/core/drizzle/0002_wide_sue_storm.sql +++ b/packages/core/drizzle/0002_windy_wind_dancer.sql @@ -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") @@ -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 $$; diff --git a/packages/core/drizzle/0003_charming_brood.sql b/packages/core/drizzle/0003_cold_spirit.sql similarity index 100% rename from packages/core/drizzle/0003_charming_brood.sql rename to packages/core/drizzle/0003_cold_spirit.sql diff --git a/packages/core/drizzle/meta/0002_snapshot.json b/packages/core/drizzle/meta/0002_snapshot.json index 37187b2d2..198d69a59 100644 --- a/packages/core/drizzle/meta/0002_snapshot.json +++ b/packages/core/drizzle/meta/0002_snapshot.json @@ -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", @@ -496,8 +496,8 @@ "primaryKey": false, "notNull": false }, - "workspace_id": { - "name": "workspace_id", + "project_id": { + "name": "project_id", "type": "bigint", "primaryKey": false, "notNull": true @@ -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" diff --git a/packages/core/drizzle/meta/0003_snapshot.json b/packages/core/drizzle/meta/0003_snapshot.json index 2ff33c737..ea4a979fd 100644 --- a/packages/core/drizzle/meta/0003_snapshot.json +++ b/packages/core/drizzle/meta/0003_snapshot.json @@ -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": { @@ -496,8 +496,8 @@ "primaryKey": false, "notNull": false }, - "workspace_id": { - "name": "workspace_id", + "project_id": { + "name": "project_id", "type": "bigint", "primaryKey": false, "notNull": true @@ -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", diff --git a/packages/core/drizzle/meta/_journal.json b/packages/core/drizzle/meta/_journal.json index 399c3e6c8..ba3a397a1 100644 --- a/packages/core/drizzle/meta/_journal.json +++ b/packages/core/drizzle/meta/_journal.json @@ -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 } ] diff --git a/packages/core/src/schema/models/commits.ts b/packages/core/src/schema/models/commits.ts index 80dbf10e7..50bd5e31d 100644 --- a/packages/core/src/schema/models/commits.ts +++ b/packages/core/src/schema/models/commits.ts @@ -13,7 +13,8 @@ import { DocumentSnapshot, documentSnapshots, latitudeSchema, - Workspace, + Project, + projects, workspaces, } from '..' import { timestamps } from '../schemaHelpers' @@ -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(), @@ -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 & { snapshots: DocumentSnapshot[] - workspace: Workspace + project: Project }