Skip to content

Commit

Permalink
fix(Database): use utc-based timestamp by default
Browse files Browse the repository at this point in the history
  • Loading branch information
9teen90nine committed Aug 8, 2023
1 parent f589b65 commit d4b2139
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- AlterTable
ALTER TABLE "Activity" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Comment" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Estimate" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "EstimateToGoal" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Filter" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Flow" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Ghost" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Goal" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "GoalAchieveCriteria" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "GoalHistory" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Job" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Project" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Reaction" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Settings" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "State" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "Tag" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);

-- AlterTable
ALTER TABLE "User" ALTER COLUMN "createdAt" SET DEFAULT timezone('utc', current_timestamp),
ALTER COLUMN "updatedAt" SET DEFAULT timezone('utc', current_timestamp);
64 changes: 32 additions & 32 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ model User {
activity Activity? @relation(fields: [activityId], references: [id])
activityId String? @unique
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model Ghost {
Expand All @@ -98,8 +98,8 @@ model Ghost {
hostId String
activity Activity?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@index([hostId])
}
Expand Down Expand Up @@ -129,8 +129,8 @@ model Activity {
goalActions GoalHistory[] @relation("goalActions")
criterion GoalAchieveCriteria[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@index([ghostId])
}
Expand All @@ -152,8 +152,8 @@ model Project {
stargizers Activity[] @relation("projectStargizers")
averageScore Int?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model Estimate {
Expand All @@ -166,8 +166,8 @@ model Estimate {
activity Activity @relation(fields: [activityId], references: [id])
activityId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@index([date])
}
Expand All @@ -179,7 +179,7 @@ model EstimateToGoal {
estimate Estimate @relation(fields: [estimateId], references: [id])
estimateId Int
createdAt DateTime @default(now())
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
@@index([goalId])
@@index([estimateId])
Expand Down Expand Up @@ -230,8 +230,8 @@ model Goal {
goalAsCriteria GoalAchieveCriteria? @relation("GoalAsCriteria")
completedCriteriaWeight Int?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@unique([projectId, scopeId])
@@index([ownerId])
Expand All @@ -248,8 +248,8 @@ model Filter {
activityId String
stargizers Activity[] @relation("filterStargizers")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model Comment {
Expand All @@ -263,8 +263,8 @@ model Comment {
stateId String?
reactions Reaction[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@index([activityId])
@@index([goalId])
Expand All @@ -280,8 +280,8 @@ model Reaction {
comment Comment? @relation(fields: [commentId], references: [id])
commentId String?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@index([activityId])
@@index([goalId])
Expand All @@ -297,8 +297,8 @@ model Flow {
states State[]
recommended Boolean?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model State {
Expand All @@ -311,8 +311,8 @@ model State {
goals Goal[] @relation("goalState")
comments Comment[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model Settings {
Expand All @@ -323,8 +323,8 @@ model Settings {
flowId String?
activity Activity?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model Tag {
Expand All @@ -336,8 +336,8 @@ model Tag {
activity Activity @relation(fields: [activityId], references: [id])
activityId String
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model Job {
Expand All @@ -351,8 +351,8 @@ model Job {
cron String?
error String?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
}

model GoalHistory {
Expand All @@ -366,7 +366,7 @@ model GoalHistory {
activity Activity @relation("goalActions", fields: [activityId], references: [id])
activityId String
createdAt DateTime @default(now())
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
@@index([id])
@@index([goalId])
Expand All @@ -385,8 +385,8 @@ model GoalAchieveCriteria {
activityId String
deleted Boolean?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @db.Timestamp()
updatedAt DateTime @default(dbgenerated("timezone('utc', current_timestamp)")) @updatedAt
@@index([title])
@@index([goalId])
Expand Down

0 comments on commit d4b2139

Please sign in to comment.