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
Branches
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', { ...@@ -36,6 +36,7 @@ const collectionTable = pgTable('collections', {
.references(() => userTable.id, {onDelete: 'cascade'}), .references(() => userTable.id, {onDelete: 'cascade'}),
collection_stats_id: integer('collection_stats_id') collection_stats_id: integer('collection_stats_id')
.notNull() .notNull()
.unique()
.references(() => collectionStatsTable.id, {onDelete: 'cascade'}), .references(() => collectionStatsTable.id, {onDelete: 'cascade'}),
}) })
......
...@@ -13,8 +13,7 @@ const commentsTable = pgTable('comments', { ...@@ -13,8 +13,7 @@ const commentsTable = pgTable('comments', {
created_at: timestamp('created_at', {mode:'string'}).notNull().defaultNow(), created_at: timestamp('created_at', {mode:'string'}).notNull().defaultNow(),
deleted_at: timestamp('deleted_at',{mode:'string'}), deleted_at: timestamp('deleted_at',{mode:'string'}),
updated_at: timestamp('updated_at', {mode:'string'}).notNull().defaultNow().$onUpdate(() => sql`current_timestamp`) updated_at: timestamp('updated_at', {mode:'string'}).notNull().defaultNow().$onUpdate(() => sql`current_timestamp`)
});
} )
const commentsModelSchema = createSelectSchema(commentsTable) const commentsModelSchema = createSelectSchema(commentsTable)
const commentsDtoSchema = commentsModelSchema.omit({}) const commentsDtoSchema = commentsModelSchema.omit({})
......
...@@ -4,15 +4,15 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod"; ...@@ -4,15 +4,15 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from "zod"; import type { z } from "zod";
import resourceTable from "./resource.schema"; import resourceTable from "./resource.schema";
import collectionTable from "./collections.schema"; import collectionTable from "./collections.schema";
import stateEnum from "./state-enum.schema"; import complaintsEnum from "./complaints-enum.schema";
const complaintTable = pgTable('complaints', { const complaintTable = pgTable('complaints', {
id: serial('id').primaryKey() id: serial('id').primaryKey()
.notNull() .notNull()
.unique(), .unique(),
state: stateEnum('state') state: complaintsEnum('state')
.notNull() .notNull()
.default('under_review'), .default('complained'),
description: text('description') description: text('description')
.notNull(), .notNull(),
denouncer_id: integer('denouncer_id') 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