chore: reformat database schema files for readability
Applied consistent formatting and indentation across all schema files using Drizzle ORM to enhance code clarity and maintainability.
This commit is contained in:
@@ -1,33 +1,63 @@
|
||||
import { pgTable, varchar, timestamp, uuid, pgEnum, index, text } from 'drizzle-orm/pg-core';
|
||||
import { users } from './users';
|
||||
import { contents } from './content';
|
||||
import { tags } from './tags';
|
||||
import {
|
||||
pgTable,
|
||||
varchar,
|
||||
timestamp,
|
||||
uuid,
|
||||
pgEnum,
|
||||
index,
|
||||
text,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { users } from "./users";
|
||||
import { contents } from "./content";
|
||||
import { tags } from "./tags";
|
||||
|
||||
export const reportStatus = pgEnum('report_status', ['pending', 'reviewed', 'resolved', 'dismissed']);
|
||||
export const reportReason = pgEnum('report_reason', ['inappropriate', 'spam', 'copyright', 'other']);
|
||||
export const reportStatus = pgEnum("report_status", [
|
||||
"pending",
|
||||
"reviewed",
|
||||
"resolved",
|
||||
"dismissed",
|
||||
]);
|
||||
export const reportReason = pgEnum("report_reason", [
|
||||
"inappropriate",
|
||||
"spam",
|
||||
"copyright",
|
||||
"other",
|
||||
]);
|
||||
|
||||
export const reports = pgTable('reports', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
reporterId: uuid('reporter_id').notNull().references(() => users.uuid, { onDelete: 'cascade' }),
|
||||
|
||||
// Le signalement peut porter sur un contenu OU un tag
|
||||
contentId: uuid('content_id').references(() => contents.id, { onDelete: 'cascade' }),
|
||||
tagId: uuid('tag_id').references(() => tags.id, { onDelete: 'cascade' }),
|
||||
|
||||
reason: reportReason('reason').notNull(),
|
||||
description: text('description'),
|
||||
status: reportStatus('status').default('pending').notNull(),
|
||||
|
||||
expiresAt: timestamp('expires_at', { withTimezone: true }), // Pour purge automatique RGPD
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
}, (table) => ({
|
||||
reporterIdx: index('reports_reporter_id_idx').on(table.reporterId),
|
||||
contentIdx: index('reports_content_id_idx').on(table.contentId),
|
||||
tagIdx: index('reports_tag_id_idx').on(table.tagId),
|
||||
statusIdx: index('reports_status_idx').on(table.status),
|
||||
expiresAtIdx: index('reports_expires_at_idx').on(table.expiresAt),
|
||||
}));
|
||||
export const reports = pgTable(
|
||||
"reports",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
reporterId: uuid("reporter_id")
|
||||
.notNull()
|
||||
.references(() => users.uuid, { onDelete: "cascade" }),
|
||||
|
||||
// Le signalement peut porter sur un contenu OU un tag
|
||||
contentId: uuid("content_id").references(() => contents.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
tagId: uuid("tag_id").references(() => tags.id, { onDelete: "cascade" }),
|
||||
|
||||
reason: reportReason("reason").notNull(),
|
||||
description: text("description"),
|
||||
status: reportStatus("status").default("pending").notNull(),
|
||||
|
||||
expiresAt: timestamp("expires_at", { withTimezone: true }), // Pour purge automatique RGPD
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
reporterIdx: index("reports_reporter_id_idx").on(table.reporterId),
|
||||
contentIdx: index("reports_content_id_idx").on(table.contentId),
|
||||
tagIdx: index("reports_tag_id_idx").on(table.tagId),
|
||||
statusIdx: index("reports_status_idx").on(table.status),
|
||||
expiresAtIdx: index("reports_expires_at_idx").on(table.expiresAt),
|
||||
}),
|
||||
);
|
||||
|
||||
export type ReportInDb = typeof reports.$inferSelect;
|
||||
export type NewReportInDb = typeof reports.$inferInsert;
|
||||
|
||||
Reference in New Issue
Block a user