sendou.ink/migrations/157-user-report.js
2026-07-18 12:46:07 +03:00

26 lines
770 B
JavaScript

export function up(db) {
db.transaction(() => {
db.prepare(
/* sql */ `
create table "UserReport" (
"id" integer primary key autoincrement,
"reportedUserId" integer not null,
"reporterUserId" integer not null,
"category" text not null,
"description" text not null,
"createdAt" integer default (strftime('%s', 'now')) not null,
foreign key ("reportedUserId") references "User"("id") on delete cascade,
foreign key ("reporterUserId") references "User"("id") on delete cascade,
unique ("reportedUserId", "reporterUserId")
) strict
`,
).run();
db.prepare(
/* sql */ `create index user_report_reported_user_id_idx on "UserReport"("reportedUserId")`,
).run();
db.pragma("foreign_key_check");
})();
}