Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- AlterTable: replace votes with separate upvotes and downvotes
ALTER TABLE `meta_posts`
ADD COLUMN `upvotes` INTEGER NOT NULL DEFAULT 0,
ADD COLUMN `downvotes` INTEGER NOT NULL DEFAULT 0;

UPDATE `meta_posts` SET `upvotes` = GREATEST(`votes`, 0), `downvotes` = GREATEST(-`votes`, 0);

-- NOTE: Intentionally keeping the `votes` column for backward compatibility with existing consumers (e.g., sw-bot).
-- Once all consumers are migrated to use `upvotes` and `downvotes`, a separate migration can safely drop `votes`.
2 changes: 2 additions & 0 deletions sw-dash/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ model MetaPost {
id Int @id @default(autoincrement())
text String @db.Text
Comment thread
Nullskulls marked this conversation as resolved.
votes Int @default(0)
upvotes Int @default(0)
downvotes Int @default(0)
metaMessageTs String? @db.VarChar(50)
votesMessageTs String? @db.VarChar(50)
createdAt DateTime @default(now())
Expand Down
Loading