api: add timestamps to sleep records
Parents:
8d8ddb93 file(s) changed
- api/prisma/migrations/20260621170628_add_timestamps_to_triggers/migration.sql +2 -2
- api/prisma/migrations/20260622031728_add_timestamps_to_sleep_records/migration.sql +18 -0
- api/prisma/schema.prisma +3 -0
api/prisma/migrations/20260621170628_add_timestamps_to_triggers/migration.sql
1 1
/*
2 2
Warnings:
3 3
4 4
- Added the required column `updated_at` to the `triggers` table without a default value. This is not possible if the table is not empty.
5 5
▸ 4 unchanged lines
10 10
ADD COLUMN "created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
11 11
ADD COLUMN "updated_at" TIMESTAMP(3);
12 12
13 13
UPDATE "triggers" SET created_at = moment, updated_at = moment;
14 14
15 -
ALTER TABLE "triggers" ALTER COLUMN created_at SET NOT NULL;
16 -
ALTER TABLE "triggers" ALTER COLUMN updated_at SET NOT NULL;
15 +
ALTER TABLE "triggers" ALTER COLUMN "created_at" SET NOT NULL;
16 +
ALTER TABLE "triggers" ALTER COLUMN "updated_at" SET NOT NULL;
api/prisma/migrations/20260622031728_add_timestamps_to_sleep_records/migration.sql
@@ -0,0 +1,18 @@
1 + /*
2 + Warnings:
3 +
4 + - Added the required column `updated_at` to the `sleep_records` table without a default value. This is not possible if the table is not empty.
5 +
6 + */
7 + -- AlterTable
8 + ALTER TABLE "sleep_records"
9 + ADD COLUMN "created_at" TIMESTAMP(3),
10 + ADD COLUMN "updated_at" TIMESTAMP(3);
11 +
12 + UPDATE "sleep_records" SET created_at = date::timestamp, updated_at = date::timestamp;
13 +
14 + ALTER TABLE "sleep_records" ALTER COLUMN "created_at" SET NOT NULL;
15 + ALTER TABLE "sleep_records" ALTER COLUMN "updated_at" SET NOT NULL;
16 +
17 + ALTER TABLE "sleep_records" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;
18 + ALTER TABLE "sleep_records" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;
api/prisma/schema.prisma
1 1
generator client {
2 2
provider = "prisma-client-js"
3 3
//output = "../src/generated/prisma"
4 4
}
5 5
▸ 106 unchanged lines
112 112
annotations String? @db.Text
113 113
114 114
userId Int @map("user_id")
115 115
user User @relation(fields: [userId], references: [id])
116 116
117 +
createdAt DateTime @default(now()) @map("created_at")
118 +
updatedAt DateTime @updatedAt @map("updated_at")
119 +
117 120
@@map("sleep_records")
118 121
}
119 122
120 123
model Insight {
121 124
id Int @id @default(autoincrement())
▸ 76 unchanged lines
198 201
FOCUS
199 202
RESTLESS
200 203
RELAXED
201 204
OVERWHELMED
202 205
}