diff --git a/store/drizzle/0000_wakeful_zodiak.sql b/store/drizzle/0000_steep_bromley.sql similarity index 94% rename from store/drizzle/0000_wakeful_zodiak.sql rename to store/drizzle/0000_steep_bromley.sql index bc250b5..e7f3917 100644 --- a/store/drizzle/0000_wakeful_zodiak.sql +++ b/store/drizzle/0000_steep_bromley.sql @@ -12,7 +12,8 @@ CREATE TABLE "nodes" ( "content" "bytea" NOT NULL, "definition" json NOT NULL, "hash" varchar(8) NOT NULL, - "previous" varchar(8) + "previous" varchar(8), + CONSTRAINT "nodes_hash_unique" UNIQUE("hash") ); --> statement-breakpoint ALTER TABLE "nodes" ADD CONSTRAINT "nodes_userId_users_name_fk" FOREIGN KEY ("userId") REFERENCES "public"."users"("name") ON DELETE no action ON UPDATE no action;--> statement-breakpoint diff --git a/store/drizzle/meta/0000_snapshot.json b/store/drizzle/meta/0000_snapshot.json index 36c2451..073363e 100644 --- a/store/drizzle/meta/0000_snapshot.json +++ b/store/drizzle/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "e0d14457-de6a-4832-80fd-ee24523ff95c", + "id": "b5fc8bcf-82d4-4d2e-bcd1-89d5a238f5e2", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -182,7 +182,15 @@ } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {}, + "uniqueConstraints": { + "nodes_hash_unique": { + "name": "nodes_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "hash" + ] + } + }, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false diff --git a/store/drizzle/meta/_journal.json b/store/drizzle/meta/_journal.json index 20760b7..9f2f80a 100644 --- a/store/drizzle/meta/_journal.json +++ b/store/drizzle/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "7", - "when": 1734695191817, - "tag": "0000_wakeful_zodiak", + "when": 1734695353420, + "tag": "0000_steep_bromley", "breakpoints": true } ] diff --git a/store/src/routes/node/node.schema.ts b/store/src/routes/node/node.schema.ts index cd5fdc8..02ee6ea 100644 --- a/store/src/routes/node/node.schema.ts +++ b/store/src/routes/node/node.schema.ts @@ -27,7 +27,7 @@ export const nodeTable = pgTable("nodes", { nodeId: varchar().notNull(), content: bytea().notNull(), definition: json().notNull(), - hash: varchar({ length: 8 }).notNull(), + hash: varchar({ length: 8 }).notNull().unique(), previous: varchar({ length: 8 }), }, (table) => [ foreignKey({