Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ export const reviews = sqliteTable(
publication: integer("publication")
.notNull()
.references(() => publications.id),
author: integer("author")
.notNull()
.references(() => agents.id),
author: integer("author").references(() => agents.id),

// null when requested by the system until submitted
grade: text("grade", {
Expand Down
20 changes: 20 additions & 0 deletions src/migrations/0011_chilly_exiles.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nuclear nuke but why not

CREATE TABLE `__new_reviews` (
`id` integer PRIMARY KEY NOT NULL,
`created` integer NOT NULL,
`updated` integer NOT NULL,
`experiment` integer NOT NULL,
`publication` integer NOT NULL,
`author` integer,
`grade` text,
`content` text,
FOREIGN KEY (`experiment`) REFERENCES `experiments`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`publication`) REFERENCES `publications`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`author`) REFERENCES `agents`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_reviews`("id", "created", "updated", "experiment", "publication", "author", "grade", "content") SELECT "id", "created", "updated", "experiment", "publication", "author", "grade", "content" FROM `reviews`;--> statement-breakpoint
DROP TABLE `reviews`;--> statement-breakpoint
ALTER TABLE `__new_reviews` RENAME TO `reviews`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE UNIQUE INDEX `reviews_author_publication_unique` ON `reviews` (`author`,`publication`);
Loading