Skip to content
Snippets Groups Projects
Commit 3a4fc5b4 authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira
Browse files

Minor fixes on BD schemas

parent f2a89574
No related branches found
No related tags found
No related merge requests found
No preview for this file type
This diff is collapsed.
......@@ -36,6 +36,7 @@ const collectionTable = pgTable('collections', {
.references(() => userTable.id, {onDelete: 'cascade'}),
collection_stats_id: integer('collection_stats_id')
.notNull()
.unique()
.references(() => collectionStatsTable.id, {onDelete: 'cascade'}),
})
......
......@@ -13,8 +13,7 @@ const commentsTable = pgTable('comments', {
created_at: timestamp('created_at', {mode:'string'}).notNull().defaultNow(),
deleted_at: timestamp('deleted_at',{mode:'string'}),
updated_at: timestamp('updated_at', {mode:'string'}).notNull().defaultNow().$onUpdate(() => sql`current_timestamp`)
} )
});
const commentsModelSchema = createSelectSchema(commentsTable)
const commentsDtoSchema = commentsModelSchema.omit({})
......
......@@ -4,15 +4,15 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from "zod";
import resourceTable from "./resource.schema";
import collectionTable from "./collections.schema";
import stateEnum from "./state-enum.schema";
import complaintsEnum from "./complaints-enum.schema";
const complaintTable = pgTable('complaints', {
id: serial('id').primaryKey()
.notNull()
.unique(),
state: stateEnum('state')
state: complaintsEnum('state')
.notNull()
.default('under_review'),
.default('complained'),
description: text('description')
.notNull(),
denouncer_id: integer('denouncer_id')
......
import { pgEnum } from "drizzle-orm/pg-core"
import { z } from "zod"
const complaintsEnum = pgEnum('complaints_state', ['complained', 'rejected', 'accepted'])
const complaintsEnumSchema = z.enum(complaintsEnum.enumValues)
export default complaintsEnum;
export type complaintsEnum = z.infer<typeof complaintsEnumSchema>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment